Yet another way: data have; input contact $ var1-var6; cards; a 1 1 1 1 1 1 b . . . 1 . 1 c 1 1 1 . . 1 d . . . 1 1 . e . 1 1 . . . f 1 . . . . 1 ; proc transpose data=have out=havelist(where=(col1 is not missing)); by contact notsorted; var var:; run; proc sql; create table haveCounts as select h1._name_ as variable, h2._name_ as col, count(*) as n from haveList as h1 inner join haveList as h2 on h1.contact=h2.contact and h1._name_ ne h2._name_ group by h1._name_, h2._name_ order by variable; drop table haveList; quit; proc transpose data=haveCounts out=want(drop=_NAME_); by variable; var n; id col; run; /* At this point you have the counts table. Now for presentation : */ option missing=""; proc sql; drop table haveCounts; select variable label="Variable", var1, var2, var3, var4, var5, var6 from want; quit; PG
... View more