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 09:25:27 -0400
Reply-To:   "Howard Schreier <hs AT dc-sug DOT org>" <schreier.junk.mail@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Howard Schreier <hs AT dc-sug DOT org>" <schreier.junk.mail@GMAIL.COM>
Subject:   Re: define a format using a macro

On Thu, 17 Jul 2008 15:32:26 -0700, maverick2 <phekuchand@GMAIL.COM> wrote:

>I have a huge dataset with a variable "date" ranging from 1990 to >present in the date20. format.

It looks like you have datetimes, not dates. They are not interchangeable, though conversion back and forth is possible.

>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?

Why presume that a macro is needed? I suspect that the solution may be much simpler. Just use the SAS-provided DTMONYY7. format.


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