Search code examples
sassas-macrosas-ods

Limiting number of observations in SAS ODS output


I'm trying to limit the number of observations included in ODS output table. My attempt is pretty basic:

OPTIONS NODATE number pageno=1 rightmargin=0.25in leftmargin=0.25in topmargin=0.4in bottommargin=0.4in;
options sysprintfont=("SAS Monospace" normal regular 8 ALL) orientation=landscape;
ODS LISTING CLOSE;
ODS NORESULTS;
ods TAGSETS.EXCELXP PATH="C:\TEMP" FILE= "&Place._RequiredFlaggedRecords.XML" STYLE=NORMALPRINTER;
/*Sets number of observations allowed per ODS*/
%let obs=100;

ODS TAGSETS.EXCELXP OPTIONS (EMBEDDED_TITLES='YES' EMBEDDED_FOOTNOTES='YES' SHEET_NAME='Outdated');
proc print data=&Place (obs=&obs) (rename = (CREATE_DATE = DATE_PROCESSED EARLIEST_DATE_TIME=VISIT_DATE_TIME EARLIEST_DATE=VISIT_DATE)) noobs;
        var
            DATEDIFF
            DATE_PROCESSED
            VISIT_DATE
            VISIT_DATE_TIME
                            ;
                WHERE DATEDIFF >=60 ;
        title1 j=l "Outdated Records " ;
        title2 j=l 'This page reflects the records which were received more than 60 days following';
RUN;

Log file returns:

NOTE: Line generated by the macro variable "OBS".
1      100
       ---
       22
       76

ERROR 22-322: Expecting a quoted string.

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.09 seconds
      cpu time            0.01 seconds

Attempted using %eval to make 100 numeric instead of character. Also replaced &obs with 100 instead of using macro. Both had same results as above.

Any help would be appreciated!


Solution

  • Most likely your problem is that you have a second set of parens. This works fine:

    ods html file="c:\temp\blah.html" path="";
    proc print data=sashelp.class(obs=10 rename=name=namer);
    run;
    ods html close;
    

    Your error is consistent with not putting obs=10 inside the parens from rename. A different error would occur if you have it like above (two sets of parens). Put all dataset options in one set of parens.

    Just to be clear, this is not an ODS related option. This is a data set option, nothing more. And macro variables don't have "types" so %eval is irrelevant here.