1
votes

I am stuck writing a piece of code that features macro variables of the form &&var&i. Let me give a small example:

%macro test;
%let i=1;
%let name1=Tom;
%put &&name&i;
%mend;
%test;

This gives a warning: "Apparent symbolic reference NAME not resolved." I thought the %put statement should resolve to

1st step: &name1 (&&-->& and &i-->1)

2nd step: Tom

It seems that in the first step already, SAS searches for the macro variable &name, although there are two ampersands in front of it.

This is the SAS log, with symbolgen enabled.

WARNING: Apparent symbolic reference NAME not resolved. 
SYMBOLGEN:  Macro variable I resolves to 1 
&&name1

Am I missing something or are there SAS settings that I should check? Thanks in advance!

1
That's very odd. Can you turn on options symbolgen, run your sample code, and add the log to your question?Quentin
@Quentin: I added the relevant part of the loglewouter
I'm flummoxed. If you batch submit or start a new SAS session and submit, does you get the same problem?Quentin
@Quentin Thanks for your suggestion. I now get the correct result. (Strange, because I had already tried it in a new session before, then without result.) Thank you for your time!lewouter

1 Answers

0
votes

Restarting the session seems to have solved the problem for you as Quentin commented.

Other options you can try if the same problem persists is turning on symbolgen option and add dot to resolve the macro variable names %put &&name&i..;