2.3.1 Step 1

Choose a wINDRESP file for a particular wave and load it, keeping only household id and this variable:

get file 's:\bhps\spss\dindresp.sav' /keep=dhid,dfimn.

Now collapse the file by household id, making a summary (the sum) of the income variable, and counting the number of individuals.

agg out = 'm:\dhinc.sav' /break=dhid
  /dtotinc=sum(dfimn)
  /dhsize=n.

Output is stored in dhinc.sav in your M:\ directory. Load it and look at it.

Stata's approach is similar, but replaces the current working file:

use dhid dfimn using ~data/bhps/dindresp
replace dfimn=. if dfimn <0
collapse (sum) totinc=dfimn, by(dhid)

Note the principle of the operation (both programs): One or more cases in the individual-level file are summarised into single cases in the grouped file.

These derived variables can be matched to the main file as above, 2.2.

Note that Stata can do both operations (aggregate and match) in one go:

sort pid
egen totinc=sum(dfimn), by(pid)



© Brendan T. Halpin (e-mail), GNU Free Documentation Licence