The SAS Output Delivery System and reporting techniques

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: 9

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

We do not currently have a macro forum, the forum you have sent this question to is mainly for ODS, PRINT, REPORT and TABULATE.

A good place to send this type of question would be to support@sas.com

This will open a track for you with SAS Technical Support. This is very helpful when you have follow up questions as all the information is kept together within the tracking number given to you.

Here is a valuable link that discusses the different ways of contacting SAS Technical Support:

http://support.sas.com/techsup/contact/index.html

To answer your question, you are correct as the %DO handles whole integer numbers, but here is a link that points to an FAQ with a work-around:

http://support.sas.com/faq/036/FAQ03635.html

If you have any further questions regarding this issue please send e-mail to support@sas.com and we at SAS Technical Support will be happy to assist you.

Thanks,
Russ Tyndall
Occasional Contributor
Posts: 10

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

Not the correct forum but shouldn't stop you from getting an answer.

%Macro NLLoop( StartI= , StopI= , ByI= ,
StartJ= , StopJ= , ByJ= ) ;

%Local I J MacIterI MaxIterJ ;

%Let MaxIterI = %SysEvalF( ( &StopI - &StartI ) / &ByI ) ;
%Let MaxIterJ = %SysEvalF( ( &StopJ - &StartJ ) / &ByJ ) ;

%Do I = 0 %To &MaxIterI ;
%Do J = 0 %To &MaxIterJ ;

Proc NLMixed
Data = &DataIn ;
Parms Beta1 = %SysEvalF( &StartI + ( &ByI * &I ) ) ,
Beta2 = %SysEvalF( &StartJ + ( &ByJ * &J ) ) ,
S2E = 1 ,
S2Beta = 1 ;
Model Y ~ Normal( Beta1 + Beta2 + BetaVar , S2E ) ;
Random BetaVar ~ Normal( 0 , S2Beta ) Subject = SID ;
Run ;

%End ;
%End ;

%Mend ;
%Mend NLLoop ;


%NLLoop( DataIn = DataSet1 ,
StartI = 1 , StopI = 2 , ByI = 0.1 ,
StartJ = 1 , StopJ = 2 , ByJ = 0.1 )
Ask a Question
Discussion stats
  • 2 replies
  • 222 views
  • 0 likes
  • 3 in conversation