Date: Wed, 22 Feb 2006 22:28:04 +0000
Reply-To: iw1junk@COMCAST.NET
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1junk@COMCAST.NET>
Subject: Re: Proc append/do loop
Larry,
Now for help on where to code the %DO-loop and other details, consider:
%macro combine(startday,stopday);
%local begin stop counter ;
%let begin=%sysfunc(inputn(&startday,mmddyy10.));
%let stop=%sysfunc(inputn(&stopday,mmddyy10.));
data test ;
set
%do counter = &begin. %to &stop.;
daily_aps_table_&counter /* no semi-colon */
%end ;
;
run ;
%mend combine;
%combine(02/05/06,02/08/06) /* ; - bad habit!!! */
/* if you write put semi-colons indiscriminately in programs
you will never learn to debug mistakes with semi-colons
*/
This loop writes a list of data sets instead of a list of steps to be
executed. There is no advantage to PROC APPEND in this case and there
is a disadvantage. Or maybe a better design would be
%macro combine(startday,stopday);
%local begin stop counter ;
%let begin=%sysfunc(inputn(&startday,mmddyy10.));
%let stop=%sysfunc(inputn(&stopday,mmddyy10.));
%do counter = &begin. %to &stop.;
daily_aps_table_&counter /* no semi-colon */
%end ;
%mend combine;
data test ;
set %combine(02/05/06,02/08/06) ; /* good semi-colon */
run ;
Here the macro concentrates on the job to be done and leaves the usage
to the user.
One final note. I question whether it is a good idea to name data sets
with SAS date values. Since they are work data sets it probably doesn't
matter. But that suggests that perhaps those work data sets shouldn't
have been made in the first place.
Ian Whitlock
===============
Date: Wed, 22 Feb 2006 16:40:01 -0500
Reply-To: Larry Kaskey <LKaskey@TRACFONE.COM>
Sender: "SAS(r) Discussion"
From: Larry Kaskey <LKaskey@TRACFONE.COM>
Subject: Re: Proc append/do loop
Content-Type: text/plain; charset="iso-8859-1"
Thanks!! I feel kind of silly missing that, but it works so I'll chalk it
up to a lesson learned...thought my days of missing semicolons were behind
me!
-----Original Message-----
From: Jiann-Shiun Huang [mailto:Jiann-Shiun.Huang@amerus.com]
Sent: Wednesday, February 22, 2006 4:34 PM
To: SAS-L; Larry Kaskey
Subject: Re: Proc append/do loop
Larry:
In the statement
%end
there should be a semicolon after it, or it should be
%end;
J S Huang
1-515-557-3987
fax 1-515-557-2422
>>> Larry Kaskey <LKaskey@TRACFONE.COM> 2/22/2006 3:16:53 PM >>>
Can someone please tell me why the following code doesn't work? It
appears to be stuck in a loop and I am just trying to teach myself how
to write macros so my knowlege is still limited, but I can't seem to see
anything wrong with this...
options mlogic;
%macro combine(startday,stopday);
%let begin=%sysfunc(inputn(&startday,mmddyy10.));
%let stop=%sysfunc(inputn(&stopday,mmddyy10.));
%do counter = &begin. %to &stop.;
proc append base = test data =
daily_aps_table_&counter;
run;
quit;
%end
%mend combine;
%combine(02/05/06,02/08/06);
Any help would be greatly appreciated.
Thanks,
Larry Kaskey
Tracfone Wireless