Date: Mon, 12 Mar 2007 11:44:26 -0400
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: SYMPUT and macro usage in a dataset
The reason is, that the preprocessor resolves all macro-triggers, like %
and & first. So the %put is the first thing and after that the data-step
is compiled and executed. That means, that the macro variable is
assigned "too late"!
On Mon, 12 Mar 2007 21:01:18 +0530, Shanks N <shanks.n@GMAIL.COM> wrote:
>"toby dunn" <tobydunn@hotmail.com> writes:
>
>> Shanks ,
>>
>> Odds are it was left over from a previous run. Since you use a %put
>> it will get executed before your code even runs. So it has to be
>> from a previous run. If I were you I would clear all macro vars out
>> of memory and then rerun it it should throw an warning atleast at
>> you.
>>
>
>Yes, it does throw a warning when I restart the SAS session but why
>wasn't the first row picked up and the second one processed? I
>haven't figured out why still.
>
>
>
>--8<---------------cut here---------------start------------->8---
>1 options symbolgen mprint mlogic;
>2 data control;
>3 input dsn $ noobs;
>4 cards;
>
>NOTE: The data set WORK.CONTROL has 2 observations and 2 variables.
>NOTE: DATA statement used (Total process time):
> real time 0.28 seconds
> cpu time 0.03 seconds
>
>
>7 ;
>8 run;
>9
>10 %macro ppp(ds,nb);
>11 proc print data=sashelp.&ds (obs=&nb);
>12 run;
>13 %mend;
>14
>15 data _null_;
>16 set control;
>17 call symput('dsname',dsn);
>18 call symputx('nob',noobs);
>19 %put ds=&dsname, obs=&nob;
>WARNING: Apparent symbolic reference DSNAME not resolved.
>WARNING: Apparent symbolic reference NOB not resolved.
>ds=&dsname, obs=&nob
>20
>21 %ppp(&dsname,&nob);
>MLOGIC(PPP): Beginning execution.
>WARNING: Apparent symbolic reference DSNAME not resolved.
>WARNING: Apparent symbolic reference NOB not resolved.
>MLOGIC(PPP): Parameter DS has value &dsname
>MLOGIC(PPP): Parameter NB has value &nob
>
>NOTE: There were 2 observations read from the data set WORK.CONTROL.
>NOTE: DATA statement used (Total process time):
> real time 0.17 seconds
> cpu time 0.07 seconds
>
>
>SYMBOLGEN: Macro variable DS resolves to &dsname
>SYMBOLGEN: Macro variable DSNAME resolves to class
>SYMBOLGEN: Macro variable NB resolves to &nob
>SYMBOLGEN: Macro variable NOB resolves to 6
>MPRINT(PPP): proc print data=sashelp.class (obs=6);
>MPRINT(PPP): run;
>
>NOTE: There were 6 observations read from the data set SASHELP.CLASS.
>NOTE: PROCEDURE PRINT used (Total process time):
> real time 0.29 seconds
> cpu time 0.07 seconds
>
>
>MLOGIC(PPP): Ending execution.
>22
>23 /*commented out for now */
>24 * call execute ('%ppp(&dsname,&nob)');
>25 run;
>--8<---------------cut here---------------end--------------->8---
|