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 (July 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 18 Jul 2008 10:55:56 +0530
Reply-To:     Anindya Mozumdar <anindya.lugbang@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Anindya Mozumdar <anindya.lugbang@GMAIL.COM>
Subject:      Re: define a format using a macro
Comments: To: maverick2 <phekuchand@gmail.com>
In-Reply-To:  <58753a81-65ca-44a9-bab6-6e4436e4c9a8@z66g2000hsc.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

This should work -

compress(put(month(datepart(date)),z2.) || ":" || put(datepart(date),monyy5.))

Not tested, but you should get the general idea

On Fri, Jul 18, 2008 at 4:02 AM, maverick2 <phekuchand@gmail.com> wrote: > 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? >


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