Yes as per my knowledge you will have to generate values for missing account numbers. Ff you don't populate id for each comorbidity then SAS will group all missing values as one id. Following code should work for you: proc format; value zero . = '0'; run; data Have(drop=PrevAccountnum); set Have; format count zero.; retain PrevAccountnum; if missing(Accountnum) then Accountnum=PrevAccountnum; else PrevAccountnum=Accountnum; Count=1; run; proc sort data=Have; by Accountnum Comorbidities; run; proc transpose data=have out=want(drop=_name_); id Comorbidities; by Accountnum; var count; run;
... View more