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
SAS Super FREQ
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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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