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;
2 REPLIES 2
Russ_SAS
SAS Employee
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
TobyDunn_hotmail_com
Fluorite | Level 6
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 )

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1029 views
  • 0 likes
  • 3 in conversation