|Date: ||Wed, 24 Jan 2007 14:33:47 -0600|
|Reply-To: ||"Paul A. Thompson" <paul@WUBIOS.WUSTL.EDU>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||"Paul A. Thompson" <paul@WUBIOS.WUSTL.EDU>|
|Subject: ||Re: Macro Variable Problem (or should I say, coder problem)|
|Content-Type: ||text/plain; charset="us-ascii"|
That's a problem with CALL EXECUTE. You can't use it for this sort of
thing. When you are doing that sort of macro assignment, CALL EXECUTE has a
problem. I don't know a work-around but one might exist.
Here is a better approach. In this approach, you go through the data and
make "macro arrays" by appending a number to the macro variable. Then, you
loop through the values.
%do _i=1 %to &_tot;
Of course, you now need to ensure that the multiple run in macro _macrun
produce identifiable output.
Why don't you ask Ron? He's right there at cdc, isn't he?
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Lamias,
Mark (CDC/CCID/OD) (CTR)
Sent: Wednesday, January 24, 2007 2:22 PM
Subject: Macro Variable Problem (or should I say, coder problem)
I am working on a piece of macro code that uses "call execute" to loop
through a dataset and pass parameters to a macro. The macro should then
execute proc sql statements and place the selected variable into a new
macro variable (via a select into statement). Then the new macro
variable should be used throughout the remainder of the macro to be used
in data manipulations, etc.
The problem I am running into is that the macro variable that is created
during the proc sql statement does not seem to change during each call
to the macro. However, the macro variable DOES seems to change if I
just hard-code several calls to the macro statement.
For your reference, I have provided a simplified version of what I am
trying to do (using the sashelp.class for this example).
proc sql noprint;
select age into :MVage
call execute('%AgeChange(' || compress(name) || ');' );
If I hard code
Instead of executing the data _null_ block of code above, I get the
following as expected in the log:
However, if I run the data _null_ block of code which should be making
the same "%AgeChange()" calls to the macro, I do not get these results.
It appears the macro variables created in the select into statement are
not resolving correctly after each iteration through the looptable. So
my question is: how can I get them to resolve correctly (or at least the
way I'm intending them to) at each iteration?
Thanks for your help.
Mark J. Lamias