Date: Tue, 4 Nov 2008 12:57:00 -0500
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: How Can Reslove a macro in If statement ??
Only a few remarks to the macro facility:
of course you can write a %let statement into a data-step, that will only
not do what you want!
Macro is a meta-language which does nothing more than generating text.
That text is generated before a data-step is compiled and executed, so
contents of a datastep variable are not available in that moment.
That is very useful in many circumstances. You can dynamicly change
programs which is a strong feature, but like Joe wrote, not in your case!
For your purpose, you are in a DATA step and have all the strengths of the
SAS language available.
Macro facility might be useful in such a program for importing a date-
value from somewhere into the step, or to export one of the values (eg.
the max-date) to make it globally available for another step or a title,
That you must do while the datastep is active, the CALL SYMPUT
("macrovar",value) is available for that.
On Tue, 4 Nov 2008 11:51:31 -0500, Joe Matise <snoopy369@GMAIL.COM> wrote:
>You can't use macro let statements inside the data step. You should be
>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
> If date not In ('nd' 'un' '' 'na' ) Then Do;
> If Length(date) = 9 Then
> Else If Length(date) = 7 Then
> Else Mhstdtc = date;
>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
>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.
>On Tue, Nov 4, 2008 at 10:45 AM, SAS_learner <firstname.lastname@example.org>
>> Hello _all_,
>> I am doing something like for getting the dates into ISO 8601 format,
>> 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
>> Else If Length(&date.) = 7 Then
>> Else Mhstdtc = &date.;