LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2003, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 5 Sep 2003 10:38:15 -0400
Reply-To:     Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject:      Re: Proc Freq, Macro question
Comments: To: "Mohamedshah, Yusuf" <Yusuf.Mohamedshah@FHWA.DOT.GOV>
Content-Type: text/plain


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.

-----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.


Yusuf Mohamedshah Program Manager LENDIS Corporation Federal Highway Administration 6300 Georgetown Pike McLean, VA 22101

Back to: Top of message | Previous page | Main SAS-L page