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:24:40 -0400
Reply-To:     "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM>
Subject:      Re: Proc Freq, Macro question
Content-Type: text/plain; charset="iso-8859-1"

Yusuf:

%let keepvars = acctype cause1 severity light weather;

%macro tabs; %let tables = %str(); %let i = 1; %do %until(%scan(&keepvars,&i,' ') = %str()); %let var = %scan(&keepvars,&i,' '); %let tables = &tables tables &var / out = &var %str(;); %let i = %eval(&i + 1); %end; &tables %mend tabs;

proc freq data = xyz; %tabs; run;

-----Original Message----- From: Mohamedshah, Yusuf [mailto:Yusuf.Mohamedshah@FHWA.DOT.GOV] Sent: September 5, 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


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