You didn't post some DATA yet . Code: Program data have; input INT_NAME HH_Area HH_ADDR REF_PT HHID HH_NAME_1 SEX_1 HH_NAME_2 SEX_2; n+1; cards; 1 1 1 1 1 11 0 12 1 1 1 1 1 1 22 0 22 1 1 1 1 1 2 11 0 12 1 1 1 1 1 2 22 0 22 1 1 1 1 1 2 33 0 32 1 ; run; proc transpose data=have out=temp; by INT_NAME HH_Area HH_ADDR REF_PT HHID n; var HH_NAME_: SEX_: ; run; data temp; set temp; id=input(scan(_name_,-1,'_'),best32.); name=prxchange('s/_\d+$//',1,strip(_name_)); run; proc sort data=temp(drop=_name_) out=x ; by INT_NAME HH_Area HH_ADDR REF_PT HHID id; run; data x; set x; by INT_NAME HH_Area HH_ADDR REF_PT HHID n notsorted; group+first.n; run; proc transpose data=x out=want; by INT_NAME HH_Area HH_ADDR REF_PT HHID group; var col1; id name; run;
... View more