This preview shows page 1. Sign up to view the full content.
Unformatted text preview: cro variables are added to a TITLE statement, so the report states how it is sorted. There are two calls to the macro, producing two reports. * For sortvar enter the variable for sorting the report. or do not enter a value for an ascending sequence; %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) %sortandprint(sortseq=, sortvar=Class) The first call to the macro gives the &SORTSEQ macro variable the value DESCENDING and the &SORTVAR macro variable the value Price. So the statements generated by this call will sort the data by descending values of the variable Price. The second call to the macro gives &SORTSEQ no value and &SORTVAR the value Class. So this call will produce statements that sort the data by ascending (the default) Class. Here are the SAS statements that are generated by the macro processor: PROC SORT DATA = models; BY Descending Price; PROC PRINT DATA = models NOOBS; TITLE 'Current Models'; TITLE2 "Sorted by Descending Price"; VAR Model Class Frame Price; FORMAT Price DOLLAR6.; RUN; PROC SORT DATA = models; BY Class; PROC PRINT DATA = models NOOBS; TITLE 'Current Models'; TITLE2 "Sorted by Class"; VAR Model Class Frame Price; FORMAT Price DOLLAR6.; RUN; For sortseq use either Descending 6 SUGI 29 Tutorials Here are the results o f the two PROC PRINTs, one sorted by descending Price, the other by Class.
Current Models Sorted by Descending Price Model Scirocco Mistral Jet Stream Nor'easter Black Bora Trade Wind Santa Ana Delta Breeze Class Mountain Road Track Mountain Track Road Mountain Road Frame Titanium Carbon Comp CroMoly Aluminum Aluminum Aluminum Aluminum CroMoly Price $2,256 $1,995 $1,130 $899 $796 $759 $459 $399 Current Models Sorted by Class Model Scirocco Nor'easter Santa Ana Mistral Trade Wind Delta Breeze Jet Stream Black Bora Class Mountain Mountain Mountain Road Road Road Track Track Frame Titanium Aluminum Aluminum Carbon Comp Aluminum CroMoly CroMoly Aluminum Price $2,256 $899 $459 $1,995 $759 $399 $1,130 $796 MPRINT system opt...
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.
- Spring '11