LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (October 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 5 Oct 2011 09:58:00 -0400
Reply-To:   bbser 2009 <bbser2009@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   bbser 2009 <bbser2009@GMAIL.COM>
Subject:   Re: Is there a macro function that will evaluate or call function ?
Comments:   To: Tom Abernathy <tom.abernathy@gmail.com>
In-Reply-To:   <201110051342.p95AlPAn026217@waikiki.cc.uga.edu>
Content-Type:   text/plain; charset="us-ascii"

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


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