Date: Tue, 31 Mar 2009 09:12:53 -0700
Reply-To: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject: Re: How to execute a macro containing a macro
In-Reply-To: <d86c1574-c13f-4f5b-9880-fdf7ddaae832@j8g2000yql.googlegroups.com>
Content-Type: text/plain; charset=windows-1252
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Chris Jones
> Sent: Tuesday, March 31, 2009 2:17 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: How to execute a macro containing a macro
>
> On 31 Mar, 10:00, ash007 <RamsamyAsh...@gmail.com> wrote:
> > thanks.
> >
> > here my code now :
> >
> > %MACRO AUTO_TYP_ADH
> > (
> > __YEAR =
> > );
> > %DO I = 1 %TO 12;
> > put &I z2.;
> > %TYP_ADH
> > (
> > __INPUTTABLE1 =
> %SYSFUNC(COMPRESS((SRC.TW_&__YEAR.&I.01))),
> > __INPUTTABLE2 = CODE_TARIF_SANTE_2008,
> > __OUTPUTTABLE =
> %SYSFUNC(COMPRESS((SRCTA.TW_&__YEAR.&I.01)))
> > );
> > %END;
> > %MEND AUTO_TYP_ADH;
> >
> > %AUTO_TYP_ADH
> > (
> > __YEAR = 2008
> > );
> >
> > why I can't tell SAS that put &I z2.; because I need SRC.TW_20080101
> > and not SRC.TW_2008101 for i = 1.
>
> You need to create a second macro variable (z2. formatted) off the
> back of &I...
> e.g.
>
> %DO I = 1 %TO 12 ;
> %LET Z = %SYSFUNC(putn(&I,z2.)) ;
> <other code, using &Z instead of &I>
> %END ;
SAS date functions and formats are your friends, get to know them . :-)
%SYSFUNC(COMPRESS((SRC.TW_&__YEAR.&I.01)))
Could become
STR._%SYSFUNC(mdy(&I,1,&__YEAR))
Whether you should be writing this macro in this way is an open question. But, in general, don't write macros unless you really need to.
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
|