BookmarkSubscribeRSS Feed
Colxfile
Calcite | Level 5
Towards the top of my program, I have:

%LOCAL ix;
%LET ix = 1;
%DO ix = 1 %to 4;
%LOCAL corra_&ix;
%LET corra_&ix = 9999;
...
%END;

This compiles and runs without problems. I call %PUT _USER_ and I see all my variables defined among the others I have. (I've initialised them to 9999 because I can see later if any operations have been carried out later)

My problem is coming later on:

%do i = 1 %to 4;
...
CALL SYMPUT(%quote('CORRA_&i'), trim(left(put(DEPEN&i,5.3))));
...
%end;

When the program runs, I want the result to be
CALL SYMPUT('CORRA_1', trim(left(...)));
CALL SYMPUT('CORRA_2', trim(left(...)));
CALL SYMPUT('CORRA_3', trim(left(...)));
CALL SYMPUT('CORRA_4', trim(left(...)));

But I cannot for the life of me work out how to correctly resolve this. I'm either receiving notes in my log that my variable is uninitialised, or that the 'Apparent Symbolic Reference is not resolved'. In any case, when I use %PUT _USER_; later on, the variables are still equal to 9999.

What should I put in place of the bold text to make this work?

Thanks in advance.
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi,
Run this test. [pre]
%let i = 5;
data _null_;
depen5 = 64.3;
CALL SYMPUT("CORRA_&i", trim(left(put(DEPEN&i,5.3))));
run;

%put _user_;
[/pre]
Unless you need the single quotes for something else that was going on in the program, you can replace the %quote function with double quotes and the resolution should be OK.
cynthia

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 1 reply
  • 1092 views
  • 0 likes
  • 2 in conversation