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 (May 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 13 May 2008 22:15:08 +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: Macro variable problem: year/month date value conversion
Comments: To: susie.li@boehringer-ingelheim.com
In-Reply-To:  <91A7A16D54C7C54B92398BFBA953A80002EE6A28@RDGEXM03.am.boehringer.com>
Content-Type: text/plain; charset="iso-8859-1"

Have no clue why you are making this a macro I have no clue as it is a simple procedure to do this and unless you have some overwhelming reason why I wouldnt. Secondly I would not do this in a data step unless you also plan on doing something else to the data. Otherwise do it this way and it will save you a pass through the data as Proc DataSets only processes the header info for a file.

Proc DataSets Lib = Work ; Modify XXX ; Rename TRT = Mic_200803 ; Run ; Quit ;

Toby Dunn

"Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch

"Be prepared. Luck is where preparation meets opportunity." Randy Pausch

> Date: Tue, 13 May 2008 17:51:56 -0400 > From: susie.li@BOEHRINGER-INGELHEIM.COM > Subject: Re: Macro variable problem: year/month date value conversion > To: SAS-L@LISTSERV.UGA.EDU > > Thank you. Your fix worked. > > Susie Chung Li > > -----Original Message----- > From: data _null_, [mailto:datanull@gmail.com] > Sent: Tuesday, May 13, 2008 5:34 PM > To: Li,Susie MK BIP-US-R > Cc: SAS-L@listserv.uga.edu > Subject: Re: Macro variable problem: year/month date value conversion > > You can't do it that way using CALL SYMPUT and then trying to use the > value in the same step. This may be more helpful to you... > > %let endmo=1mar2008; > data mic; > trx=1; > run; > %macro test(dsn=); > %let yyyymm = %sysfunc(intnx(month,"&endmo"d,0),yymmn6); > %put NOTE YYYYMM=<&yyyymm>; > data &dsn; > set &dsn (rename=trx=&dsn._trx_&yyyymm); > run; > %mend; > > options mprint; > %test(dsn=mic); > > You may want to consider an completely different approach. Keeping > data in the meta data fields of a SAS data set does not make for the > most efficient coding. We would need to see the big picture to make a > more useful recommendation. > > On 5/13/08, Susie C Y Li wrote: >> Hello all, >> >> I would like to get a variable name "trx" changed to something like >> "mic_200803" by running the following code. But it failed. Can you help? >> >> >> ------- code ------ >> >> %let endmo=1mar2008; >> %macro test(dsn=); >> data &dsn; >> sasdate=intnx('month',"endmo"d,0)); >> call symput('yyyymm',put(sasdate,yymmn6.)); >> set &dsn (rename=trx=&dsn._trx_&yyyymm); >> run; >> %mend; >> >> %test(dsn=mic); >> >> ----- log --------- >> >> MPRINT(RUNMARKET): ; >> SYMBOLGEN: Macro variable DSN resolves to mic >> MPRINT(RENAMEIT): data mic; >> SYMBOLGEN: Macro variable ENDMO resolves to 01mar2008 >> MPRINT(RENAMEIT): sasdate=intnx('month',"01mar2008"d,0); >> MPRINT(RENAMEIT): call symput('yyyymm',put(sasdate,yymmn6.)); >> SYMBOLGEN: Macro variable DSN resolves to mic >> WARNING: Apparent symbolic reference YYYYMM not resolved. >> >> >> >> >> Susie Chung Li >>

_________________________________________________________________ Make Windows Vista more reliable and secure with Windows Vista Service Pack 1. http://www.windowsvista.com/SP1?WT.mc_id=hotmailvistasp1banner


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