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 (November 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 4 Nov 2008 11:51:31 -0500
Reply-To:   Joe Matise <snoopy369@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Joe Matise <snoopy369@GMAIL.COM>
Subject:   Re: How Can Reslove a macro in If statement ??
Comments:   To: SAS_learner <proccontents@gmail.com>
In-Reply-To:   <c2192a610811040745r35071980p257e3b713080b8a0@mail.gmail.com>
Content-Type:   text/plain; charset=ISO-8859-1

You can't use macro let statements inside the data step. You should be able to do this without a macro variable...

Data test ; set test ; format date $20.; *make sure this is long enough; date = Mehbegdf; *if necessary, and make sure it's the right length for possible values;

If date not In ('nd' 'un' '' 'na' ) Then Do;

If Length(date) = 9 Then

Mhstdtc=Cats(Substr(date,6,4),'-',Put(Substr(date,3,3),$Monthf.),'-',Substr(date,1,2)); Else If Length(date) = 7 Then Mhstdtc=Cats(Substr(date,4,4),'-',Put(Substr(date,1,3),$Monthf.)); Else Mhstdtc = date; Run;

However, I suspect your best answer is going to be to figure out how to input your date string into an actual SAS date, and then output it into the format you prefer. If you have more detailed specifications for what format(s) it can start out in, this would be fairly easy to do.

-Joe

On Tue, Nov 4, 2008 at 10:45 AM, SAS_learner <proccontents@gmail.com> wrote:

> Hello _all_, > > I am doing something like for getting the dates into ISO 8601 format, but > somehow date is not getting resolved after IF statement > I am not sure If I need to make date as global to get it resolved ?? > > If you think of a better way to write this macro please let me know > > Data test ; > set test ; > %let date = %str(Mehbegdf); > > If &date. Not In ('nd' 'un' '' 'na' ) Then Do; > > If Length(&date.) = 9 Then > > > Mhstdtc=Cats(Substr(&date.,6,4),'-',Put(Substr(&date.,3,3),$Monthf.),'-',Substr(&date.,1,2)); > > Else If Length(&date.) = 7 Then > Mhstdtc=Cats(Substr(&date.,4,4),'-',Put(Substr(&date.,1,3),$Monthf.)); > Else Mhstdtc = &date.; > > Run; > > TIA > SL >


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