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