%macro genother(setin,variable,mincount); %let revdate=7/22/2003 8:30AM; %*---this macro will generate an $other format code that can be used to recode values of a character variable in a sas dataset that occur less than &mincount times in that dataset. See Sample use, below. ---------; %if %nrbquote(&setin) = %str() or %nrbquote(&variable) = %str() or %nrbquote(&mincount) = %str() %then %do; %put; %put ****Required 3 positional parms: setin, variable, mincount -- not coded.****; %put **** No code will be generated by genother macro ****; %goto endmac; %end; proc sql noprint; select distinct &variable into :_values separated by '","' from &setin group by &variable having count(*) < &mincount; proc format; value $other "&_values"="Other"; run; %endmac: %mend genother; /* Sample use : %genother(system.webpgms,program,5) *--creates the $other format code that assigns the label "Other" to all values of variable program in input dataset system.webpgms. We will now make use of the format code in the freq report to lump these values into the other category.; proc freq data=system.webpgms; table program; format program $other16.; run; */