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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1268 views
  • 0 likes
  • 4 in conversation