09-11-2013 10:38 AM
pls guide me on
How to Write some macro code to do a PROC FREQ on a dataset called TEMP, running the macro 3 times to produce tables for variables A, B and C. Use variable D to weight the results. The weight, the name of the dataset and the names of the variables should be parameterised, so this macro could be used for any variables on any dataset
09-11-2013 10:48 AM
Here is a macro that would do what you want ... is there a reason you want a macro instead of just listing all the variables you need on the table statement?
proc freq data=&ds;
%freq(temp, A, D):
%freq(temp, B, D):
%freq(temp, C, D):
09-11-2013 11:30 AM
And actually EJ's macro will work with a call like:
%freq(temp, A B C, D);
If the data set is large putting the all the table variables in one call will run faster as the data set will only be read once.
Though I would have made the parameters keyword parameters.