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?
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.
Look at your second parameter of call symput. It's misspelled.
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.
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.
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.
Always post into the code windows while they are open (Pop-up). Posting into the field within the main posting window eats linefeeds.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.