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
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);
%LET C = %EVAL ( 1234 * &i );
But I don't understand why you call macro A without any argument (i=&i).
Regards - Jim.
Jim Groeneveld, Netherlands
Statistician, SAS consultant
On Tue, 17 Oct 2006 15:14:57 -0400, Yu Zhang <zhangyu05@GMAIL.COM> wrote:
>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);
>call symput('c',left(put(c,8. -l)));
>%do i=1 %to &k;
> %a ------------->the text substitution caused problem.
>I know people like Toby will question the design issue. Let's put aside
>the design. How Can I make it work?