| Date: | Thu, 28 Apr 2005 05:08:42 +0000 |
| Reply-To: | toby dunn <tobydunn@HOTMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | toby dunn <tobydunn@HOTMAIL.COM> |
| Subject: | Re: Problem with Nested Macros |
|
| In-Reply-To: | <20050428030205.6172.qmail@webmail7.rediffmail.com> |
| Content-Type: | text/plain; format=flowed |
|---|
sa polo,
%macro test(yymm=) ;
%local FirstDate ;
%let FirstDayOfMonth = %sysfunc(inputn(&yymm.01,yymmdd10.)) ;
data _null_ ;
LastDayofMonth = intnx('MONTH',&FirstDayOfMonth,0,'END') ;
do i = &FirstDayOfMonth to LastDayofMonth ;
start = intnx('Day',&FirstDayOfMonth,i) - &FirstDayOfMonth ;
if (2 le weekday(start) le 6 ) then do ;
xx = put(start,YYMMDDN8.) ;
yy = compress('flags_fiveT1A_'||xx||'.csv') ;
put xx= ;
end;
end;
run;
%mend ;
%test(yymm=200503) ;
HTH
Toby Dunn
From: sa polo <solouga2@REDIFFMAIL.COM>
Reply-To: sa polo <solouga2@rediffmail.com>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Problem with Nested Macros
Date: Thu, 28 Apr 2005 03:02:05 -0000
Hello All;
I am unsuccessfully attempting to run a macro within a macro .
The macro %RunDates takes a year and month and passes all
WEEKDAYS to a second macro %RunMe which prints the string that is
passed to it.
%MACRO RunMe(xx);
DATA _NULL_;
PUT xx=&xx;
RUN;
%MEND;
%MACRO RunDates(YYMM);
data _null_;
FirstDay=TRIM(LEFT(PUT(&YYMM,z6.)))||TRIM(LEFT(PUT(01,z2.)));
FirstDaySAS=INPUT(FirstDay,YYMMDD10.);
PUT FirstDaySAS=date7.;
Last_Day_of_Month=INTNX('MONTH',FirstDaySAS,0,'END');
PUT Last_Day_of_Month=date7.;
do i = FirstDaySAS to Last_Day_of_Month;
start=intnx('Day',FirstDaySAS,i)-FirstDaySAS;
if 2 <= weekday(start) <= 6 then do;
put start=date7.;
xx=PUT(start,YYMMDDN8.);
yy=COMPRESS('flags_fiveT1A_' ||xx ||'.csv');
CALL EXECUTE( %RunMe(xx));
end;
end;
run;
%MEND;
%RunDates(200503)
Any help is much appreciated.
Sa
|