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;

sas-innovate-2024.png

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.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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