handout_sas_09_SAS_Macro

However if you specify the mprint sys tem option in

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ion We have been showing you what SAS sees after the macro processor has resolved your program, but normally you won't see these statements. However if you specify the MPRINT sys tem option in your program, then SAS will print the resolved statements from macros in the SAS log. This can be very useful for debugging purposes. To turn on the MPRINT option, submit an OPTIONS statement like this: OPTIONS MPRINT; Here is what the SAS log looks like with the MPRINT option turned on: 6 7 8 9 10 11 12 13 14 15 16 %MACRO sortandprint(sortseq=, sortvar=); PROC SORT DATA=models; BY &sortseq &sortvar; PROC PRINT DATA=models NOOBS; TITLE 'Current Models'; TITLE2 "Sorted by &sortseq &sortvar"; VAR Model Class Frame Price; FORMAT Price DOLLAR6.; RUN; %MEND sortandprint; %sortandprint(sortseq=Descending, sortvar=Price); PROC SORT DATA=models; BY Descending Price; MPRINT(SORTANDPRINT): MPRINT(SORTANDPRINT): NOTE: There were 8 observations read from the data set WORK.MODELS. 7 SUGI 29 Tutorials NOTE: The data set WORK.MODELS has 8 observations and 4 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.55 seconds cpu time 0.05 seconds MPRINT(SORTANDPRINT): MPRINT(SORTANDPRINT): MPRINT(SORTANDPRINT): MPRINT(SORTANDPRINT): MPRINT(SORTANDPRINT): MPRINT(SORTANDPRINT): PROC PRINT DATA=models NOOBS; TITLE 'Current Models'; TITLE2 "Sorted by Descending Price"; VAR Model Class Frame Price; FORMAT Price DOLLAR6.; RUN; NOTE: There were 8 observations read from the data set WORK.MODELS. NOTE: PROCEDURE PRINT used (Total process time): real time 0.81 seconds cpu time 0.07 seconds 17 %sortandprint(sortseq=, sortvar=Class); MPRINT(SORTANDPRINT): PROC SORT DATA=models; MPRINT(SORTANDPRINT): BY Class; NOTE: There were 8 observations read from the data set WORK.MODELS. NOTE: The data set WORK.MODELS has 8 observations and 4 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.04 seconds cpu time 0.03 seconds MPRINT(SORTANDPRINT): MPRINT(SORTANDPRINT): MPRINT(SORTANDPRINT): MPRINT(SORTANDPRINT): MPRINT(SOR...
View Full Document

This note was uploaded on 03/21/2013 for the course AMS 597 taught by Professor Xing during the Spring '11 term at SUNY Stony Brook.

Ask a homework question - tutors are online