Hi ... here's another approach that works with your multiple moms. It uses a format as a lookup table to assign the PERSONIDs as a mother or father ... data one; input dwellingid : $4. personid : $3. id : $8. (momid dadid) (: $3.); datalines; 1001 101 1001_101 N/A N/A 1001 102 1001_102 N/A N/A 1001 103 1001_103 N/A N/A 1001 104 1001_104 101 102 1001 105 1001_105 103 102 ; run; proc sql; create table momdad (where=(start ne 'N/A')) as select distinct momid as start, '10' as label, '$momdad' as fmtname from one union select distinct dadid as start, '01' as label, '$momdad' as fmtname from one; quit; proc format cntlin=momdad; run; data two; set one; mother = ifc(momid eq 'N/A', char(put(personid,$momdad.),1), '0'); father = ifc(dadid eq 'N/A', char(put(personid,$momdad.),2), '0'); run; proc print data=two noobs; run; dwellingid personid id momid dadid mother father 1001 101 1001_101 N/A N/A 1 0 1001 102 1001_102 N/A N/A 0 1 1001 103 1001_103 N/A N/A 1 0 1001 104 1001_104 101 102 0 0 1001 105 1001_105 103 102 0 0
... View more