BookmarkSubscribeRSS Feed
DanielM
Calcite | Level 5
In proc NLmixed, I am attemping to run a loop that changes the starting parameter values. The do-loop will only allow me to step by integer values, but I need to step by values of 0.1. Here is what I have so far:

%macro iterate(i,j);
proc nlmixed data=dataset1;
parms beta1=&i,
beta2=&j,
s2e=1,
s2beta=1;

model Y ~ normal(beta1+beta2+betavar,s2e);
random betavar ~ normal(0,s2beta) subject=sid;
run;
%mend iterate;

%macro looped;
%do i=1 %to 2 %by 1;
%do j=1 %to 2 %by 1;
%iterate(&i,&j);
%end;
%end;
%mend looped;

%looped;
1 REPLY 1
Dave_SAS
SAS Employee
You can modify the code so that within the iterate macro, you divide the incoming parameters by 10. The following sample code may help you -- no guarantees expressed or implied.

I've changed the upper bounds of the do loop to 20 instead of 2 as well.

%macro iterate(i,j);
data _null_;
temp_i= &i/10;
temp_j= &j/10;
call symput ("new_i",temp_i);
call symput ("new_j", temp_j);
run;

%put "&new_i &new_j";
/*
proc nlmixed data=dataset1;
parms beta1=&new_i,
beta2=&new_j,
s2e=1,
s2beta=1;

model Y ~ normal(beta1+beta2+betavar,s2e);
random betavar ~ normal(0,s2beta) subject=sid;
run;
*/
%mend iterate;

%macro looped;
%do i=1 %to 20 %by 1;
%do j=1 %to 20 %by 1;
%iterate(&i,&j);
%end;
%end;
%mend looped;

%looped;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 1 reply
  • 2136 views
  • 0 likes
  • 2 in conversation