BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GKati
Pyrite | Level 9

Dear All,

 

I am trying to save parameters as a macro:

data t0;
length Parameter $15;
input Parameter $ Estimate;
datalines;
Intercept 1132
;
run;

*store the estimated parameters;
data _null_;
 set t0;
 if Parameter = "Intercept" then 
 call symput('Ibar', Esimate);
run;

%put &Ibar;

 

 

I get the message that IBar was not saved properly:

SYMBOLGEN: Macro variable IBAR resolves to .

 

Why can"t I save the value?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Your corrected code, posted with the "little running man", looks like this:

data t0;
length Parameter $15;
input Parameter $ Estimate;
datalines;
Intercept 1132
;
run;

*store the estimated parameters;
data _null_;
set t0;
if Parameter = "Intercept" then call symput('Ibar', Estimate);
run;

%put &Ibar;

You can see the advantages of posting code in the right manner.

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Is that exactly how you typed it, with many SAS commands on the same line?

 

Not only is this a bad practice, but I believe it is why the commands fail.

 

You need to put each command on it's own line

 

Furthermore the line that reads 

Intercept 1132

 

should be on a line without a semicolon, and the semicolon that follows should be on the next line. 

 

Then, you need to spell the variable name exactly the same in both the DATA T0; step, and in the DATA _NULL_; step.

--
Paige Miller
Kurt_Bremser
Super User

Your corrected code, posted with the "little running man", looks like this:

data t0;
length Parameter $15;
input Parameter $ Estimate;
datalines;
Intercept 1132
;
run;

*store the estimated parameters;
data _null_;
set t0;
if Parameter = "Intercept" then call symput('Ibar', Estimate);
run;

%put &Ibar;

You can see the advantages of posting code in the right manner.

GKati
Pyrite | Level 9

Thanks for the help. This was copy-pasted in the "running man" line by line as suggested below. I don't know why the display changed after posting. 

 

 

Kurt_Bremser
Super User

Always post into the code windows while they are open (Pop-up). Posting into the field within the main posting window eats linefeeds.

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

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1842 views
  • 0 likes
  • 3 in conversation