Revision: 34706
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 27, 2010 09:07 by sandman7OR
Initial Code
*** ORDER MACRO ***; * This macro creates a format that will order PROC REPORT across columns; * according to the order the values are input, see examples below; * &order is a pipe(|) delimited list of values to be ordered; * &fmtname is the name of the format statement to be output; %macro order_fmt(fmtname=,order=); %local icol ncol nspace ispace space; /* Start defining format */ proc format; value &fmtname /* Loop over the columns specified in &order */ %let ncol = %sysfunc(countw(%bquote(&order),|)); %do icol = 1 %to &ncol; /* Prefix formatted values with spaces to enforce ordering*/ %let nspace = %eval(&ncol + 1 - &icol); %let space = %str(); %do ispace = 1 %to &nspace; %let space = &space%str( ); %end; /* Format line - TRIM assumes that input data does not have prefix spaces*/ "%qleft(%qtrim(%qscan(&order,&icol,|)))" = "&space%qleft(%qtrim(%qscan(&order,&icol,|)))" %end; ; run; %mend order_fmt;
Initial URL
Initial Description
Initial Title
Macro to create an ordering (for PROC REPORT)
Initial Tags
Initial Language
SAS