Hi, I have a dataset where I need to left shift a set of variables based upon an indicator variable. The data are in sets, with the indicator denoted as key ( i.e. key1, b1, c1, key2, b2, c2, etc. relate to each other) If the indicator variable is missing then the set is deleted and everything should then left shift. Missing values are allowable in all variables but the indicator. I can left-shift the variables individually using the array below by running it separately for key, b & c. The problem is then the left shift doesn't depend on the indicator and the variables become misaligned. Is it possible to put the arrays together to make everything happen at once and depend on the indicator variable? I'm running SAS Enterprise v7.15. I would really appreciate your suggestions. Best, Lyn data have; input id key1 key2 key3 b1 b2 b3 c1 c2 c3; cards; 1 1 2 3 1 2 3 1 2 3 2 . 2 3 1 2 3 1 2 . 3 1 . 3 1 2 . 1 2 3 4 1 2 3 . 2 3 1 . 3 ; run; data want; input id key1 key2 key3 b1 b2 b3 c1 c2 c3; cards; 1 1 2 3 1 2 3 1 2 3 2 2 3 . 2 3 . 2 . . 3 1 3 . 1 . . 1 3 . 4 1 2 3 . 2 3 1 . 3 ; run; data have2; set have; array j{*} key1-key3; array x{3} _temporary_; n=0;call missing(of x{*}); do i=1 to dim(j); if not missing(j{i}) then do; n+1;x{n}=j{i}; end; end; do i=1 to dim(j); j{i}=x{i}; end; drop i n; run;
... View more