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;
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.
Try something like-->
data _null_;
set t0;
do i= 1 to 8;
if beta = i then
call symput(cats('ibar',i), Estimate);
end;
run;
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.
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.
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 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.