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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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