Do loops with non-integer index values for macros

Reply
New Contributor
Posts: 2

Do loops with non-integer index values for macros

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;
SAS Employee
Posts: 27

Re: Do loops with non-integer index values for macros

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;
Post a Question
Discussion Stats
  • 1 reply
  • 581 views
  • 0 likes
  • 2 in conversation