LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 18 Oct 2006 02:37:08 -0400
Reply-To:     Jim Groeneveld <jim2stat@YAHOO.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Groeneveld <jim2stat@YAHOO.CO.UK>
Subject:      Re: How to reference a macro vatiable generated from a macro
              within a separated macro
Comments: To: Yu Zhang <zhangyu05@GMAIL.COM>

Hi Yu,

I've been following all discussions on this subject and I think you have to know the possibilities and limitations of SAS. I agree to the other respondents (Toby, David, DATA_NULL_, etc.), but I would like to point you to some improvement in your code that might have made it possible to do what you wanted, despite its ugly and unnecessarily far to complex design. In your macro A you only use a _NULL_ data step to calculate something and assign it to a macro variable. You can do this without a data step, only using macro code, in which case you actually may call macro A from macro B at the desired location.

So you macro A would become:

%macro a (i); %global c; %LET C = %EVAL ( 1234 * &i ); %mend;

But I don't understand why you call macro A without any argument (i=&i).

Regards - Jim. -- Jim Groeneveld, Netherlands Statistician, SAS consultant home.hccnet.nl/jim.groeneveld

On Tue, 17 Oct 2006 15:14:57 -0400, Yu Zhang <zhangyu05@GMAIL.COM> wrote:

>Hi, All, > >I was wondering if there is a way to implement this: > >Suppose I need a macro to generate a macro variable. there is a or more >data steps in that macro. the last data step will create a macro variable >through CAll symput. > >Now I have a separated macro. Also there are several datasteps in it. in >one of the datastep, I need to call first one to create a macro variable >so that I can use it for calculations. > >I made up a sample code below: > >%macro a (i); >%global c; >data _null_; >c=1234*&i; >call symput('c',left(put(c,8. -l))); >run; >%mend; > > >%macro b(k); >data x; >x=12; >%do i=1 %to &k; > %a ------------->the text substitution caused problem. > C&i=12+&c; > %end; > run; > %mend; > > %b(2) > > > >I know people like Toby will question the design issue. Let's put aside >the design. How Can I make it work? > >Thanks > >Yu


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