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 macro value. I have a variable called beta with values 1-8, represented beta1 - beta8. I would like to save each betaas as a macro value called 1bar-8bar, but I am having trouble with the naming of the variable 'ibar' in the symput statement: 

 

How could I achieve this or similar result?

 

*store the estimated parameters;
data _null_;
 set t0;
do i= 1 to 8;
if beta = i then 
 call symput('ibar', Estimate);
end;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post some test data, I can't see anything from that code.  Also, why do you want to put things into macro paramters?  Datasets are for data.  You cannot have macro variables (or any variables) called Xbar, where X is a number, this is invalid as variables need to start with a non-numeric value.  Also, if you have multiple rows, then ibar may get overwritten each time.  Of course without data I can't say for sure.  Perhaps post test data, and what you want to see as 100% sure there is a better method.

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

Try something like-->

data _null_;
 set t0;
do i= 1 to 8;
if beta = i then 
 call symput(cats('ibar',i), Estimate);
end;
run;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post some test data, I can't see anything from that code.  Also, why do you want to put things into macro paramters?  Datasets are for data.  You cannot have macro variables (or any variables) called Xbar, where X is a number, this is invalid as variables need to start with a non-numeric value.  Also, if you have multiple rows, then ibar may get overwritten each time.  Of course without data I can't say for sure.  Perhaps post test data, and what you want to see as 100% sure there is a better method.

Reeza
Super User

You cannot start with a macro variable name with a number per the naming rules. If you do _ibar or bari instead, either would likely work. 

 


1    %let 8bar=2;
ERROR: Expecting a variable name after %LET.
2    %put &8bar.;
&8bar.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 855 views
  • 0 likes
  • 4 in conversation