data have;
input ID age dx :$15. weight test :$15.;
datalines;
1 29 covid 140 covid
. . flu . blood_pressure
. . diabetes . .
2 33 high_bp 165 covid
. . gest_diab . blood_pressure
. . preeclamp . .
;
data temp;
set have;
retain _id _age;
if not missing(id) then _id=id;
if not missing(age) then _age=age;
drop id age;
run;
proc sql noprint;
select max(n) into :n
from (select count(*) as n from temp group by _id,_age);
quit;
proc summary data=temp nway;
class _id _age;
output out=want idgroup(out[&n.] (dx weight test)=);
run;
... View more