Date: Fri, 18 Jul 2008 17:14:03 -0400
Reply-To: Ed Heaton <EdHeaton@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ed Heaton <EdHeaton@WESTAT.COM>
Subject: Re: define a format using a macro
In-Reply-To: <58753a81-65ca-44a9-bab6-6e4436e4c9a8@z66g2000hsc.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"
Data _null_ ;
date = '07JAN2007:00:00:00'DT ;
Format date dateTime. ;
Put date= ;
date = intNX( 'month' , datePart(date) , 0 ) * '24:00:00't ;
Put date= ;
Run ;
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
maverick2
Sent: Thursday, July 17, 2008 6:32 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: define a format using a macro
I have a huge dataset with a variable "date" ranging from 1990 to
present in the date20. format. For any particular range of dates, i need
to define a new variable "period". eg. if
'01JAN2007:0:0'DT<=date<='31JAN2007:0:0'DT then period='01:JAN07'; else
if '01FEB2007:0:0'DT<=date<='28FEB2007:0:0'DT then period='02:FEB07';
Of course I can write out the entire condition every single time, but
thats too time consuming.
Is there any way to write a macro so that it creates the variable
"period" that contains the formated label for "date"? (format as in
'01JAN2007:0:0'DT - '31JAN2007:0:0'DT = '01:JAN07' and so on.)
So basically, I just run the macro which would format the "date"variable
to "period", so that I have a count of all such periods?