03-10-2015 12:33 PM
I have 12 numeric variables (values of either 0,1,2) an am hoping to create a single variable which counts the number of "1"s or "2"s across rows (I have over 20 000 obs); e.g. how many 2s or 1s are in each row/record (rows can have both 1 or 2 - so wont be able to divide out) - I know there must be a simple way of doing this but haven't had much luck yet - any help would be greatly appreciated? Thanks so much!
03-10-2015 01:04 PM
Have you tried an array and do loop or are you looking for something different?
array vars(12) var1-var12;
do i=1 to dim(vars);
if vars(i) in (1,2) then var_count+1;
03-10-2015 01:09 PM