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