|
Yusuf,
You already have good answers, but I would add that the design will be
clearer with
proc freq data = xyz;
%tabs(vars=acctype cause1 severity light weather);
run;
or I would probably include the PROC in the macro and write
%freqout(data = xyz, vars=acctype cause1 severity light weather)
Notice that with the last line the reader can make a pretty simple guess
that frequency data sets will be made. With code suggested before, the
reader knows with certainty that freqs will be done and on which tables, but
not that there will be output datasets. With your original plan, he knows
the some freqs will be made, but knows not which ones or anything about
output datasets without studying more code, i.e. using more read time.
IanWhitlock@westat.com
-----Original Message-----
From: Mohamedshah, Yusuf [mailto:Yusuf.Mohamedshah@FHWA.DOT.GOV]
Sent: Friday, September 05, 2003 10:13 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Proc Freq, Macro question
I want to dynamically generate multiple table statements for a freq
procedure. Let me elaborate:
I have a big macro that does some QC runs. In one of the segments of the
macro I want to generate multiple table statements based on a number of
variables that are specified in a macro variable.
For example:
If I define %let keepvars = acctype cause1 severity light weather;
I want to generate following proc freq:
proc freq data = xyz;
tables acctype / out = acctype;
tables cause1 / out = cause1;
tables severity / out = severity;
tables light / out = light;
tables weather / out = weather;
run;
I was trying to come up with a macro so that the freq would be like:
proc freq data = xyz;
%tabs;
run;
where %tabs would have above mentioned multiple table statements. I have
tried to code an array statement inside %tabs macro but it does not seem to
work. Also the number of variables in keepvars will vary from database to
database.
Any help and/or suggestions would be helpful.
Thanks
Yusuf Mohamedshah
Program Manager
LENDIS Corporation
Federal Highway Administration
6300 Georgetown Pike
McLean, VA 22101
|