Hi all, I would like to do the same thing (see below) in PROC IML. I created two variables and output observations based on values of "b". data test; input a b; cards; 1 0 2 1 3 2 4 0 5 1 6 2 7 0 ; run; data test1 test2 test3; set test; if b=0 then output test1; else if b=1 output test2; else output test3; run; With only two groups, I tried the syntax below and it worked. proc iml; a={1, 2, 3, 4, 5, 6, 7}; *a vector with random numbers; b={0, 1, 0, 0, 1, 0, 1}; *a vector indicating the group membership; c=t(remove(a,loc(b))); *elements from a when b=0; d=t(remove(a,loc(element(a,c)))); *elements from a when b=1; quit; BUT, I have difficulty if there are three groups such as: a={1, 2, 3, 4, 5, 6, 7}; b={0, 1, 2, 0, 1, 2, 1}; I can create SAS data set to save those values and then to output to three SAS data sets. But I would like to learn how to achieve this in PROC IML. Thanks to all!
... View more