Date: Tue, 17 Oct 2006 15:55:32 -0500
Reply-To: Yu Zhang <zhangyu05@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Yu Zhang <zhangyu05@GMAIL.COM>
Subject: Re: How to reference a macro vatiable generated from a macro
within a separated macro
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
thank you so much for all of your suggestions.
You are right about that "You may have a situation that is screaming for a
OK, back to my question.
this is not real work I am doing. I just want to make sure there is no way I
can implement it using macro,
initially I have something like this:
do i=1 to 3;
call symput('ii',left(put(i,8. -l)));
call symput('rec',left(put(d,8. -l)));
I was wondering if I can do same thing with macro. Aslo if more and more
datastep elements are added. the code is not readable. For example, array
definitions, do loop etc.
As you said, we cannot run a datastep within a datastep. I think macro is
not suitable tool to this problem.
Aslo, you mentioned that "there are other ways to compute a data point (or a
of them) and have the data available later in the program".Could you please
give some examples? you don't have to write any codes.
I hope you could understand my question better this time.
Thank you so much!
On 10/17/06, David L Cassell <email@example.com> wrote:
> zhangyu05@GMAIL.COM wrote:
> >data _null_,
> >thank you for taking time to answer my question.
> >what I am trying to do is create a macro varaible on the fly and use it
> >later part of program.
> Why? And why make the second part of the process so hard?
> Really. I'm (trying to be) serious about this.
> First off, I don't like creating global variables if I don't have to. I
> like to carefully control my macro variable scope so I don't have to
> worry about things like namespace collisions and making macros too
> unwieldy to re-use.
> Second, there are other ways to compute a data point (or a bunch
> of them) and have the data available later in the program. A macro
> variable may be a good approach, but it is not the only approach.
> Third, using that created macro should be *transparent*. It is,
> after all, just the 'text substitution' you talked about earlier. Needing
> an entire data step to cope with it seems counter-intuitive.
> Fourth, a complex process may be a lot easier to write the first
> time if you start out with a non-macro solution (that may only work
> for special case) and then macro-ize it to get what you need.
> >I know I can take out the data _null_ and run statements from first
> >but there going to be many many repeated statements in one datastep when
> >is resolved.
> Why? What do the "many many repeated statements" do?
> You may have a situation that is screaming for a macro solution.
> But you may have a situation which is done better with other
> >Do you have any suggestion or idea of how to make it happen?
> My suggestion here is for you to explain in great detail what your
> process needs to do, and why, so that the people on SAS-L can
> give you better advice than the kvetching above.
> David L. Cassell
> mathematical statistician
> Design Pathways
> 3115 NW Norwood Pl.
> Corvallis OR 97330
> Use your PC to make calls at very low rates