Date: Thu, 30 Jun 2011 15:20:16 +0000
Reply-To: "DUELL, BOB (ATTCINW)" <bd9439@ATT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "DUELL, BOB (ATTCINW)" <bd9439@ATT.COM>
Subject: Re: macro: symbolic reference not resolved
In-Reply-To: <201106300556.p5U3fTbq023650@waikiki.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
Hi Franco,
I think the warning message is from the macro compilation phase because CALL SYMPUTX is creating the four macro variables in the GLOBAL environment such that they don't exist in the macros LOCAL environment. When the macro actually executes, those variables have been created.
Try adding a %GLOBAL statement at the top of your macro:
%GLOBAL nrowsA nrowsB nrowsC nrowsD;
Another thing you could do is change your program to use SAS data step variables rather than macro variables. In other words, get rid of the first data _null_ step and add the following to top of your _Isquare data step:
retain nrowsA nrowsB nrowsC nrowsD;
if _n_ = 1 then do;
if 0 then set &vars._1 nobs=nrowsA;
if 0 then set &vars._2 nobs=nrowsB;
if 0 then set &vars._3 nobs=nrowsC;
if 0 then set &vars._4 nobs=nrowsD;
end;
Then of course change the macro variable references to variable references.
Hope this helps,
Bob
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Franco Grex
Sent: Wednesday, June 29, 2011 10:56 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: macro: symbolic reference not resolved
Hi, this macro below gives the expected results but I keep getting the
warnings:
apparent symbolic reference to 'NROWSA' (and 'NROWSB' 'NROWSC'
'NROWSD') not resolves?
%macro matcher (vars);
data _null_;
if 0 then set &vars._1 nobs=nA;
call symputx('nrowsA',nA);
if 0 then set &vars._2 nobs=nB;
call symputx('nrowsB',nB);
if 0 then set &vars._3 nobs=nC;
call symputx('nrowsC',nC);
if 0 then set &vars._4 nobs=nD;
call symputx('nrowsD',nD);
stop;
run;
data &vars._Isquare (keep = pt1 retsas1-retsas6);
array pt(1) $ 20;
pt(1)= "&vars";
array arrA(&nrowsA) $ 50 _temporary_;
array arrB(&nrowsB) $ 50 _temporary_;
array arrC(&nrowsC) $ 50 _temporary_;
array arrD(&nrowsD) $ 50 _temporary_;
do i=1 to &nrowsA;
set &vars._1;
arrA(i) = Location||Age||Sex||Income||N_1;
end;
NvarA=dim(arrA) * 50;
do i=1 to &nrowsB;
set &vars._2;
arrB(i) = Location||Age||Sex||Income||N_2;
end;
NvarB=dim(arrB) * 50;
do i=1 to &nrowsC;
set &vars._3;
arrC(i) = Location||Age||Sex||Income||N_3;
end;
NvarC=dim(arrC) * 50;
do i=1 to &nrowsD;
set &vars._4;
arrD(i) = Location||Age||Sex||Income||N_4;
end;
NvarD=dim(arrD) * 50;
array retsas(6);
call module ("library, function", arrA(1), NvarA, arrB(1),
NvarB, arrC(1), NvarC,
arrD(1), NvarD, retsas(1));
run;
proc append base=Output_data data=&vars._Isquare force;
run;
proc datasets;
delete &vars.A_1 &vars.B_2 &vars.C_3 &vars.D_4
&vars._1 &vars._2 &vars._3 &vars._4 &vars._Isquare; run;
%mend;
*Execute the program;
data _null_;
set mydataset;
call execute('%matcher('||name||')');
run;
Thanks
|