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 (March 1997, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 12 Mar 1997 17:35:32 -0600
Reply-To:   txplltw@UABCVSR.CVSR.UAB.EDU
Sender:   "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:   Todd Weiss <txplltw@UABCVSR.CVSR.UAB.EDU>
Subject:   Re: Marco assistance
Comments:   To: "Alderton, David" <dla5@CIDHIV1.EM.CDC.GOV>
In-Reply-To:   <>
Content-Type:   TEXT/PLAIN; charset=US-ASCII

Hi David,

Off the top of my head, something like the following could be modified to suit your needs:

data test; input a b c; cards; 1 . . 2 . . 4 1 . . 2 1 2 3 4 ; run;

%let varl=a b c;

%macro parse(list); %let i=1; %do %while (%scan (&list, &i) ne ); %let val=%scan (&list, &i);

proc freq data=test; tables &val / out = &val;

%*data step stuff;

Data &val; set &val; if &val ne .; run;

%let i=%eval(&i +1); %end; %mend;


Good Luck,

Todd Weiss

On Wed, 12 Mar 1997, Alderton, David wrote:

> Does anyone have an example of a simple macro that accepts a list of > unrelated items and uses the list to, e.g., subset datasets? > > Right now I'm using a %let / %include pair like this: > > %let oi=TB; > %include "&oi_path"; > > %let oi=PLB; > %include "&oi_path"; > > etc., > > The include file consists of a bunch of simple file manipulations dependent > upon the value of &oi, e.g., as below (actually, 4 sets of the following > within each include). > > proc freq data=New_ASD ; > weight asd_wgt ; > table &oi / out=asdwt noprint ; > by dyr; > run; > > data asdwt; > set asdwt; > retain cnt 0 ; > by dyr; > if first.dyr then cnt=count; > else cnt=cnt+count; > asdwtper=percent; > asdwt=count; > asdwt_N=cnt; > label asdwtper='ASD weighted %'; > if &oi='0' then delete; > drop &oi count cnt percent; > run; > > One of the problems I'm having is that the OI list is an unrelated series of > character strings, TB, PC, MAV, WAST, KS, CERV_CA, etc. (27 of them is the > maximum) and I don't know how to frame this in a macro context. The include > works just fine but I thought I would look for a macro solution to learn how > to do it and to keep all of the code in the same file. > > Any suggestions or samples would be greatly appreciated. I've been looking > at the SAS guide to macro processing (version 6) and SAS Macro Facility but > I cannot find an example that appears to be similar enough for me to grasp > the relationship. Most of the examples use names generated from a list, > like week1, week2, week3, etc. > > Thanks, David. > David L. Alderton, Ph.D. > Centers for Disease Control and Prevention > HIV/AIDS Surveillance Branch > Atlanta, GA -- >

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