|
Richard might want one macro-stone for two birds.
I tried to solve this using a macro, but got a problem for d2.
Code is attached below. Could anyone please help me make it work? Thanks.
Best regards, Max
(Maaxx)
====================
options mlogic mprint symbolgen;
%macro richard(date);
%local firstchar;
%let firstchar=%substr(&date,1,1);
%put &firstchar;
%if &firstchar=m %then
%sysfunc(&date);
%else
%sysevalf(&date);
%mend richard;
%let d1=mdy(1,1,2011);
%let d2="01JUN2011"d;
%put %richard(&d1);
%put %richard(&d2);
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tom
Abernathy
Sent: October-05-11 9:42 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: [SAS-L] Is there a macro function that will evaluate or call
function ?
Richard -
I am not sure what the question is?
When you converted to all macro you should have used
%let d1_expr = %sysfunc(mdy(1,1,2011));
instead of
%let d1_expr = mdy(1,1,2011);
- Tom
On Wed, 5 Oct 2011 09:05:03 -0400, Richard DeVenezia <rdevenezia@GMAIL.COM>
wrote:
>Hello:
>
>* DATA Step has the benefit of a compiler that determines how an
>expression is handled.
>
>data _null_;
> * data has its benefits;
> d1 = mdy(1,1,2011);
> d2 = '01-jun-2011'D;
> put (d:) (=/);
>run;
>
>* MACRO does not have the same benefit;
>
>options nosource;
>%let d1_expr = mdy(1,1,2011);
>%let d2_expr = '01-jun-2011'D;
>
>%put d1_eval = %sysevalf (&d1_expr.); %* not works;
>%put d1_rslt = %sysfunc (&d1_expr.); %* works;
>%put d2_eval = %sysevalf (&d2_expr.); %* works;
>%put d2_rslt = %sysfunc (&d2_expr.); %* not works;
>
>* looking for magic;
>%put d1_magic = eval or func (&d1_expr.); %* works;
>%put d2_magic = eval or func (&d2_expr.); %* works;
>
>
>
>Any ideas for a macroized system where a date is specified for one of
>the parameters
>
>Thanks,
>Richard
|