Hi, I am looking for a proc sql approach to summarize a set of variables that have only 3 states of Valid, Missing, or OOR (out of range) values and represented by 0, 1, or 2, respectively. In the data set below, there are two groups with four variables that have 3 states (0,1, or 2). data have; length grp $1 v1 v2 v3 v4 4; input grp v1 v2 v3 v4 ; datalines; 1 0 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 1 0 1 2 1 1 0 2 2 1 1 0 2 2 1 2 2 2 2 1 2 2 2 ; run; What proc sql command (or other, if needed) can generate the following output, which summarizes the count of each state by group by variable. data want; length grp $1 var $4 type0 type1 type2 4; input grp var type0 type1 type2; datalines; 1 v1 4 0 0 1 v2 2 2 0 1 v3 4 0 0 1 v4 0 4 0 2 v1 0 4 0 2 v2 0 2 2 2 v3 2 0 2 2 v4 0 0 4 ; run; Thanking you in advance, rg
... View more