Hi,

I’m working with hierarchical data from the Current Population Survey. Each household (QSTNUM) has members defined by their line number (PULINENO). There are pointer variables for each individual record that indicate the line number of their mother or father within the household (PELNMOM and PELNDAD). I want to add an indicator variable to person-level records indicating whether the person is a mother or father, and I am having trouble figuring out how to do this. I would be grateful for any help.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long qstnum byte(pulineno pelnmom pelndad)
   77 1 -1 -1
   77 6 -1 -1
   77 3  1  6
   77 5  1  6
   77 4  1  6
   77 2  1  6
 7374 1 -1 -1
28232 1 -1 -1
28232 3  1 -1
28232 2  1 -1
15832 1 -1 -1
15832 2 -1 -1
57221 1 -1 -1
 2524 1 -1 -1
65433 1 -1 -1
65433 2 -1 -1
56481 1 -1 -1
 7323 1 -1 -1
 7323 3  1 -1
 7323 2  1 -1
28223 1 -1 -1
29237 1 -1 -1
29236 1 -1 -1
29236 2 -1 -1
29236 3  1  2
13096 1 -1 -1
13096 2 -1  1
 7327 1 -1 -1
 7327 2 -1 -1
61020 1 -1 -1
63496 1 -1 -1
63496 2 -1 -1
63496 3  2  1
68235 1 -1 -1
 2520 1 -1 -1
28221 1 -1 -1
23443 1 -1 -1
23443 2 -1 -1
 7378 1 -1 -1
60392 1 -1 -1
 7363 1 -1 -1
 7363 2 -1 -1
61024 1 -1 -1
61024 2 -1 -1
45548 1 -1 -1
45548 5  1 -1
45548 4  1 -1
45548 3  1 -1
45548 2  1 -1
36158 1 -1 -1
57206 1 -1 -1
57206 2 -1 -1
57206 3  2  1
 7384 1 -1 -1
 7384 2 -1 -1
 7384 6  1  2
 7384 5  1  2
 7384 4  1  2
 7384 3  1  2
45520 1 -1 -1
45520 2 -1 -1
29238 1 -1 -1
29238 2 -1 -1
29238 4  2  1
29238 3  2  1
   57 1 -1 -1
 2097 1 -1 -1
 2097 2 -1 -1
73392 1 -1 -1
28219 1 -1 -1
28219 2 -1 -1
23457 1 -1 -1
23457 2 -1 -1
13137 1 -1 -1
 7380 1 -1 -1
36117 1 -1 -1
14391 1 -1 -1
14391 2 -1 -1
14391 3  2  1
14391 4  2  1
14391 5  2  1
14389 1 -1 -1
14389 3  1 -1
73390 1 -1 -1
57220 1 -1 -1
57220 2 -1 -1
45547 1 -1 -1
23491 1 -1 -1
23491 2  1 -1
36143 1 -1 -1
36143 2 -1 -1
36143 3  2  1
13126 1 -1 -1
28226 1 -1 -1
28226 5  1 -1
28226 4  1 -1
28226 3  1 -1
28226 2  1 -1
 2511 1 -1 -1
 2511 2 -1 -1
end
label values pelnmom pelnmom
label def pelnmom -1 "NO MOTHER PRESENT", modify
label values pelndad pelndad
label def pelndad -1 "NO FATHER PRESENT", modify