| Date: | Thu, 8 Feb 1996 12:44:00 +0100 |
| Reply-To: | Frank Poppe <poppe@SWOV.NL> |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | Frank Poppe <poppe@SWOV.NL> |
| Subject: | SYMGET and SYMPUT [WAS: Re: Help with another macro problem] |
|
Hi,
Several people have responded to the question of using macro variables
created with call symput in the same datastep.
It appears to be possible to get the right value back using call symget. I
tried the example from Karsten Self below and it works (on VMS, SAS 6.08).
data _null_;
x = 'I''m not really here';
call symput( 'mv', x );
y= symget( 'mv' );
put y= ;
run;
And it works the first time, no quesion about that.
John Whittington pointed out that this fails when the macro variable is
referenced directly ( y=&mv).
The difference is (in my view) caused by the fact that SYMPUT and SYMGET are
interface mechanisms between the datastep and the macro environment, which
apparently works different than the direct reference.
I think of this interfacing mechanism as an area where SYMPUT writes
information during the execution of the data step. At the end of the data
step this information is transferred to the global macro environment.
This global macro environment is transferred to this intermediate area
At the beginning of the data step the current macro environment is copied to
this area, and SYMGET tries to find its information there.
That could explain why SYMGET is able to find information supplied by SYMPUT
in this interface area, while the direct reference (which look "outside" in
the macro environment) can not find this information. It will not be placed
there until the end of the data step.
Would this be a way of thinking, that (conceptually) explains what is going
on?
And always keep in mind Ian Whitlock's observation:
" The understanding of the distinctions between and order of
1) macro compile
2) macro execution
3) SAS compile
4) SAS execution
seems to be a major stumbling block to writing SAS macros."
+--------------------------------------------------+
| Frank Poppe poppe@swov.nl
| Institute for Road Safety Research SWOV
| PO Box 170
| 2260 AD Leidschendam
| the Netherlands
| telephone +31 70 320 9323
| fax +31 70 320 1261
+------------------------------------------
|