I am trying to save a vector named ez
product of some matrix calculations based on a group variable named ID_bloque
. For each ID_bloque
value my code computes a vector called ez
and append it in a matrix with the same name. However, if zk
is a missing data vector (which is not a mistake) the code stops and make no other computations, which is a problem for other groups since no calculations are made for them. Is there any way to force append
clause to keep this data and those resulting for the other groups? Thank you so much
proc iml;
/*Maximo= maximum ID_bloque value*/
do i=1 to %EVAL(&MAXIMO);
use T6; /*Dataset*/
/*Variables*/
read all var{E1S1 E1S2 E2S1 E2S2 E3S1 E3S2 E4S1 E4S2}
into XK where (ID_bloque=i) ;
read all var{FEX_P} into dk where (ID_bloque=i) ;
read all var{VK} into vk where (ID_bloque=i) ;
read all var{z} into zk where (ID_bloque=i) ;
/* Matrix computations */
MAT=J(NCOL(XK),NCOL(XK),0);
do j=1 to Nrow(XK);
MAT= MAT + dk[j]*vk[j]*((XK[j,]`)*XK[j,]);
end;
/* ez values depending on missing information in zk*/
if all(zk)=. then do;
ez=zk;
end;
else do;
Brz=(Ginv(MAT))*((XK`)*(dk#vk#zk));
ez=zk-XK*Brz;
end;
/* Vectors appending (error source) */
if i=1 then do;
create ez var{ez}; APPEND;
end;else do; APPEND var{ez} ;end;
end;
close ez;
quit;