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:         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
Comments: To: David L Cassell <davidlcassell@msn.com>
In-Reply-To:  <BAY103-F109091D2F48267A4B4F3A5B00E0@phx.gbl>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi, David,

thank you so much for all of your suggestions.

You are right about that "You may have a situation that is screaming for a macro solution".

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:

data x; a=12; b=13; do i=1 to 3; call symput('ii',left(put(i,8. -l))); link getvar;

c=resolve('&rec'); d=c*a*i; output; end;

getvar: f=12; d=f*resolve('&ii'); call symput('rec',left(put(d,8. -l))); return; run;

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 bunch 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!

Yu

On 10/17/06, David L Cassell <davidlcassell@msn.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 > in > >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 > macro, > >but there going to be many many repeated statements in one datastep when > it > >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 > tools. > > > >Do you have any suggestion or idea of how to make it happen? > > > >Thank! > > > >Yu > > 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. > > HTH, > David > -- > David L. Cassell > mathematical statistician > Design Pathways > 3115 NW Norwood Pl. > Corvallis OR 97330 > > _________________________________________________________________ > Use your PC to make calls at very low rates > https://voiceoam.pcs.v2s.live.com/partnerredirect.aspx >


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