I am running a program that involves looping around some proc iml commands. The index variable I use is country code ('code'). The code is looking like this: %MACRO Aggregate1; %DO i= 1 %TO 46; data Vart&i; set Var1; if code=&i; run; proc varmax data=Vart&i outest=est&i noprint; model return TS / p=1 print=(estimates diagnose); output out=VARR&i; run; data estt&i (drop = const); set est&i; if type="EST" then output; run; proc iml; use estt&i; read all var _num_ into Gamma&i[colname=varNames]; rho=0.99573468; lambda&i=rho*Gamma&i*(inv(I(2)-rho*Gamma)); e1={1, 0}; c&i=t(e1)+t(e1)*(lambda&i); ec&i=(t(e1)+t(e1)*lambda&i)*(Gamma&i); d&i=t(e1)*(lambda&i); ed&i=t(e1)*(lambda&i)*(Gamma&i); create cc&i from c&i[colname={"h1&i" "h2&i"}]; append from c&i; create dd&i from d&i[colname={"h11&i" "h12&i"}]; append from d&i; create ecc&i from ec&i[colname={"h21&i" "h22&i"}]; append from ec&i; create edd&i from ed&i[colname={"h31&i" "h32&i"}]; append from ed&i; quit; data hi&i; merge Vart&i VARR&i(keep = res1 res2); run; *make temp variable to merge first part of NCF and NDR *; data hi1&i; set hi&i; temp=1; if ind2 =. then delete; run; data ccc&i; set cc&i; temp=1; run; data ddd&i; set dd&i; temp=1; run; data eccc&i; set ecc&i; temp=1; run; data eddd&i; set edd&i; temp=1; run; data final&i; merge hi1&i ccc&i ddd&i eccc&i eddd&i; by temp; run; *estimate nc_indep_nosvol and nd_indep_nosvol; data Final1&i; set Final&i; nc_ind_nosvol&i=h1&i*res1 + h2&i*res2; nd_ind_nosvol&i=h11&i*res1 + h22&i*res2 ; ec_ind_nosvol&i=h21&i*lag(return) + h22&i*lag(TS); ed_ind_nosvol&i=h31&i*lag(return) + h32&i*lag(TS); run; data Final1A&i; set Final1&i; if res1=. or res2=. then delete; run; *Appending Final Data*; proc datasets nolist; append base=CV force data=Final1A&i; %END; %mend; %Aggregate1; The original data (VAR1) I have attached to this message. The code works for one iteration, but it doesn't work if I put it in a looping format. I get the following error message: ERROR: (execution) Matrix has not been set to a value. The SAS log indicates everything before the proc iml portion of the code works, so the mistake must be in the proc iml section. Is there anything wrong there?
... View more