aggregate out = summary.sav /break = ghid /totinc = sum(indinc) /number = n. . . . get file summary.sav. compute aveinc = totinc/number.
AGGREGATE OUTFILE={file} [/MISSING=COLUMNWISE] [/DOCUMENT] {* } [/PRESORTED] /BREAK=varlist[({A})][varlist...] {D} /aggvar['label']aggvar['label']...=function(arguments)[/aggvar ...] SUM Sum MEAN Mean SD Standard deviation MAX Maximum MIN Minimum PGT % of cases gt value PLT % of cases lt value PIN % of cases between values POUT % of cases not in range FGT Fraction gt value FLT Fraction lt value FIN Fraction between values FOUT Fraction not in range N Weighted n NU Unweighted n NMISS Weighted n of missing NUMISS Unweighted n of missing FIRST First nonmissing LAST Last nonmissing
. collapse (sum) totinc=ind (count) n=apno, by(ahid) . gen aveinc = totinc/n
match files file = individual.sav /table = household.sav /by = hhid.Both files must be sorted according to hhid.
. use individual.dta . merge hhid using household.dta
. use individual.dta . sort ahid apno . egen totinc=sum(indinc), by(ahid)
match files file = wave1.sav /file = wave2.sav /* "/file" not "/table" */ /by = pid.Both files must be sorted according to pid.
. use wave1.dta . merge pid using wave2.dta
_merge
which distinguishes
the three cases
get file = "s:\bhps\spss\aindresp.sav" /keep = ahid ahgspn ajbsemp ajbft asex. select if (ahgspn gt 0). sort cases by ahid ahgspn. save out="m:\spsinfo.sav" /rename=(ahgspn ajbsemp ajbft asex = apno aspjbsem aspjbft aspsex).
get file = 's:\bhps\spss\aindresp.sav' /keep = ahid apno ajbsemp ajbft asex match files file = * /file = "m:\spsinfo.sav" /by=ahid,apno.
use ahid ahgspn ajbsemp ajbft asex using s:\bhps\stata\aindresp keep if ahgspn > 0 rename ahgspn apno rename ajbsemp aspjbsem rename ajbft aspjbft rename asex aspsex sort ahid apno save m:\spinfo, replace use ahid apno ahgspn ajbsemp ajbft asex using s:\bhps\stata\aindresp sort ahid apno merge ahid apno using m:\spinfo
|