ks619
ks619

Reputation: 23

symbolic reference in MACRO IN sas

I have been recieving an error- symbolic reference not resolved when i run the macro in sas using following code: Initially I select as set of Role Numbers using SQL into a list as:

PROC SQL NOPRINT; SELECT ROLENO INTO:R1-:R81 FROM ROLLNOS; QUIT;

Then a macro is used to select each individual marks and conoslidate them as :

options Mprint; 
%MACRO Marks; 

%DO I=1 %TO 1;
proc sql noprint;
create table Marks as select name, rollno, marks, grade from  masterdata
where rollno= "&R&I."; 
quit;

PROC APPEND DATA=Marks BASE=MarksSheet FORCE;RUN;

%END;
%MEND;
RUN;
%Marks;

I got an error when the sql statement is executed, Please help me resolve the issue. especially with referencing part- "&R&I."

Upvotes: 0

Views: 68

Answers (1)

kl78
kl78

Reputation: 1666

You want to resolve to R1.

&R&I. resolves to macarovariable R (which is not available) and macrovariable I.

You need a second & before the R, because 2 & resolve to one.

If you use &&R&I, in the first step &&R resolves to &R and &I resolves to 1, so you got &R1. This will then resolve to the macrovariable R1 in second step.

Also %do I=1 %to 1 only has one iteration, is this meant to be?

options Mprint; 
%MACRO Marks; 

 %DO I=1 %TO 1;
proc sql noprint;
create table Marks as select name, rollno, marks, grade from  masterdata
where rollno= "&&R&I."; 
quit;

PROC APPEND DATA=Marks BASE=MarksSheet FORCE;RUN;

%END;
%MEND;
%Marks;

Upvotes: 2

Related Questions