whoops. that's because I forgot to put a do loop in . try this
%macro rtm (j=31) ;
%do i = 1 %to &j ;
proc nlp noprint data=S&i absgconv=1e-15 OUTEST=T1; by obs;
bounds R>=0, R<=1;
min f;
decvar R=1;
f = abs(PRC1_IBES-(BVPS1_1+(((FEPS1_1/BVPS1_1_1)-R)/(1+R))*BVPS1_1
+(((FEPS2_1/BVPS2_1_1)-R)/((1+R)**2))*BVPS1_1_1
+(((FEPS3_1/BVPS3_1_1)-R)/((1+R)**3))*BVPS2_1_1
+(((FEPS4_1/BVPS4_1_1)-R)/((1+R)**4))*BVPS3_1_1
+(((FEPS5_1/BVPS5_1_1)-R)/((1+R)**5))*BVPS4_1_1
+(((FEPS6_1/BVPS6_1_1)-R)/((1+R)**6))*BVPS5_1_1
+(((FEPS7_1/BVPS7_1_1)-R)/((1+R)**7))*BVPS6_1_1
+(((FEPS8_1/BVPS8_1_1)-R)/((1+R)**8))*BVPS7_1_1
+(((FEPS9_1/BVPS9_1_1)-R)/((1+R)**9))*BVPS8_1_1
+(((FEPS10_1/BVPS10_1_1)-R)/((1+R)**10))*BVPS9_1_1
+(((FEPS11_1/BVPS11_1_1)-R)/((1+R)**11))*BVPS10_1_1
+(((FEPS12_1/BVPS12_1_1)-R)/(R*(1+R)**11))*BVPS11_1_1));
run;
data T1; set T1;
if _TYPE_='PARMS';
rename R=rgls1_1_1;
keep obs R; run;
data O&i; merge S&i (in=xx) T1(in=yy); by obs; if xx and yy; run;
%end;
%mend rtm;
%rtm(j=31);
Thank you very much. Your solution works perfectly. I am sorry I do not have the option to choose two right answers here. Otherwise, I would select your one too.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.