Date: Wed, 5 May 2004 13:35:09 -0400
Reply-To: "Lustig, Roger" <roger.lustig@CITIGROUP.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Lustig, Roger" <roger.lustig@CITIGROUP.COM>
Subject: Re: THANKS! RE: another newbie question / SET
Content-Type: text/plain; charset="iso-8859-1"
Helen:
To your question(s):
--The two dots have different meanings: the first one indicates where a macro variable ends and non-variable code begins. The second one is part of the code.
--No semicolon: because you don't want to *write* a semicolon there. Remember, you're using the macro to write code. The line without a semicolon is just some macro variables and some plain text--no macro statements like %if or %do. That's what the macro will write when it writes code--which is what it does.
Also, when you call the macro, you don't want a semicolon there, because macro calls don't need them; i.e., you'd be putting an actual semicolon in your code--where, as you know, you don't want it, since it's in the middle of your SET statement.
Best,
Roger
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of
Dennis, Helen
Sent: Wednesday, May 05, 2004 1:08 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: THANKS! RE: another newbie question / SET
Thank you, everyone who responded - all were helpful, but I ended up using Roger Lustig's suggestion.
This worked perfectly. One question: why are there two consecutive dots in &lib..&head.&I instead of one? Also, why is there no semicolon needed on this line?
-----Original Message-----
From: Lustig, Roger [mailto:roger.lustig@citigroup.com]
Sent: Wednesday, May 05, 2004 11:57 AM
To: Dennis, Helen; SAS-L@LISTSERV.UGA.EDU
Subject: RE: another newbie question / SET
Helen:
If you wish to enumerate the five data sets, you need a smaller macro.
Remember: =====> SAS macros write SAS code <=====
That's all they do. What you want is a macro that writes five dataset names. You don't even want to write the whole SET statement--just the stuff between the SET keyword and the semicolon. (So make sure your macro doesn't write semicolons!)
%macro namewriter(lib=work,head=,from=,to=);
%do I=&from %to &to;
&lib..&head.&I
%end;
%mend;
data hcondall;
set
%namewriter(head=helmcond,from=1,to=5)
;
run;
Note that WORK is the default library, but that you can use any other.
Note also that you can mix and match:
data stuff;
set
%namewriter(lib=mydata,head=master,from=1,to=12)
%namewriter(lib=yourdata,head=faster,from=13,to=24)
%namewriter(lib=mydata,head=disaster,from=25,to=36)
;
run;
OK?
Roger
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of
Dennis, Helen
Sent: Wednesday, May 05, 2004 11:47 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: another newbie question / SET
Thanks so much for your patient help yesterday. Now I am trying to stack five data sets using the SET command, and although I get no error message, I also get no results. Each data set has 10,000 records and 10 variables.Any suggestions?
DATA hcondall;
SET helmcond1 helmcond2 helmcond3 helmcond4 helmcond5;
Run;
I also tried this:
%MACRO appnhelm;
%DO k= 2 %TO 5;
DATA helmdata1;
set helmdata1 helmdata&k;
run;
%END
%appenhelm;
run;
Helen C. Dennis
Education Associate
Assessment and Analysis Group
Delaware Department of Education
P.O. Box 1402
Dover, DE 19903-1402
Tel: (302)739-6700 Fax: (302) 739-3092
email: hdennis@doe.k12.de.us