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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.