/* Please do not attemp to run this program without reading the accompanying documentation. */ version 8.0 set more off prog drop _all capture log close clear cd $log log using set_a$p.log, replace /* File: pull a (id and weights).do Date: May 2012 Desc: Pull-file to create Set A Note: See acknowledgements and copyright notice in new_master.do. */ /* This program is to be run embedded within master.do. The programs below pull the variables necessary for Set A from the SIPP Longitudinal, Core, and Topical Modules and merge them into one dataset that is by person-month. Note that we delete any individual who appears in a Core or Topical Module file, but who is not on the Longitudinal file, as recommended by U.S. Census Bureau staff. For the 1990-1993 panels, in order to reshape the Longitudinal files by person-month, we need to do three separate steps. (1) Pull all Longitudinal vars that appear once per panel and create a dataset that is by . (2) Pull all Longitudinal vars that appear once per wave and create a dataset that is by . (3) Pull all Longitudinal vars that appear once per month and create a dataset that is by . Generate calendar month and wave from the month counter in this file. (The variable goes from 1 to 36 in the 1993 panel and thus must be converted into calendar months for merging.) Then, we merge the three files together into one person-month file, along with variables from the Core and Topical Module files. Note that there is an error in the 1993 panel whereby there are individuals in the longitudinal file that show up without data. These are deleted. */ macro list cd $tempdata capture program drop loop08 program define loop08 global avarlist "$ids ssuseq ssuid spanel rhcalmn rhcalyr rot eentaid eppintvw epppnum shhadid whfnwgt wffinwgt wsfinwgt wpfinwgt gvarstr tage ghlfsam grgc" forvalues i=1/8 { if `i' == 1 { use $avarlist using $c`i', clear } if `i' > 1 { append using $c`i', keep($avarlist) } } rename tage age compress sort $ids cd $tempdata save test, replace *incorporate longitidinal weights sort ssuid epppnum cd $rawdata merge ssuid epppnum using sipp08lwt tab _merge keep if _merge == 3 drop _merge cd $tempdata save test, replace end capture program drop loop04 program define loop04 global avarlist "$ids ssuseq ssuid spanel rhcalmn rhcalyr rot eentaid eppintvw epppnum shhadid whfnwgt wffinwgt wsfinwgt wpfinwgt gvarstr tage ghlfsam grgc" forvalues i=1/12 { if `i' == 1 { use $avarlist using $c`i', clear } if `i' > 1 { append using $c`i', keep($avarlist) } } rename tage age compress sort $ids cd $tempdata save test, replace *incorporate longitidinal weights sort ssuid epppnum cd $rawdata merge ssuid epppnum using sipp04lwt tab _merge /* 776 observations in lwt data do not exist in core data. dropping these */ keep if _merge == 3 drop _merge cd $tempdata save test, replace end capture program drop loop01 program define loop01 local i=1 use $ids ssuseq ssuid spanel rhcalmn rhcalyr rot eentaid eppintvw epppnum /* */ shhadid whfnwgt wffinwgt wsfinwgt wpfinwgt gvarstr tage using $c`i', clear sort $ids save test, replace local i = `i'+1 while `i'>1 & `i'<10 { use $ids ssuseq ssuid spanel rhcalmn rhcalyr rot eentaid eppintvw epppnum /* */ shhadid whfnwgt wffinwgt wsfinwgt wpfinwgt gvarstr tage using $c`i', clear sort $ids append using test sort $ids save test, replace local i=`i'+1 } rename tage age sort ssuid epppnum save test, replace *incorporate longitidinal weights cd $rawdata use sipp01lwt cd $tempdata sort ssuid epppnum merge ssuid epppnum using test tab _merge /* 565 observations in lwt data do not exist in core data. dropping these */ keep if _merge == 3 drop _merge save test, replace end capture program drop loop96 program define loop96 local i=1 use $ids ssuseq ssuid spanel rhcalmn rhcalyr rot eentaid eppintvw epppnum /* */ shhadid whfnwgt wffinwgt wsfinwgt wpfinwgt gvarstr tage using $f`i', clear sort $ids save test`i', replace * gen unique state id to merge sort ssuid epppnum egen idst = concat(ssuid epppnum) sort idst wave srefmon /* You must have the BLS SIPP96 experimental weight data files for this section to run correctly. These files are available from the BLS, or CEPR. */ /* cd $rawdata merge idst wave srefmon using sipp96state`i' cd $tempdata tab _merge sum tage if statewgt==. */ sort id wave srefmon drop _merge save test`i', replace save test, replace local i = `i'+1 while `i'>1 & `i'<13 { use $ids ssuseq ssuid spanel rhcalmn rhcalyr rot eentaid eppintvw epppnum /* */ shhadid whfnwgt wffinwgt wsfinwgt wpfinwgt gvarstr tage using $f`i', clear sort $ids save test`i', replace * gen unique state id to merge sort ssuid epppnum egen idst = concat(ssuid epppnum) sort idst wave srefmon /* You must have the BLS SIPP96 experimental weight data files for this section to run correctly. These files are available from the BLS, or CEPR. */ /* cd $rawdata merge idst wave srefmon using sipp96state`i' cd $tempdata tab _merge sum tage if statewgt==. drop _merge sort $ids save test`i', replace append using test sort $ids save test, replace */ local i=`i'+1 } rename tage age save test, replace end capture program drop loop93 program define loop93 * Longitudinal data * id cd $rawdata use id suseqnum pp_entry pp_pnum pnlwgt fnlwgt93 fnlwgt94 /* */ varstrat using sipp93l1, clear cd $tempdata count if id=="" drop if id=="" sort id save testi, replace * id wave cd $rawdata use id pp_intv* using sipp93l1, clear cd $tempdata sort id reshape long pp_intv, i(id) j(wave) count if id=="" drop if id=="" sort id wave save testw, replace * id month cd $rawdata use $idr pp_mis* hh_add* age* using sipp93l1, clear cd $tempdata renpfix age_ age renpfix age0 age renpfix hh_add0 hh_add renpfix pp_mis0 pp_mis sort id reshape long hh_add pp_mis age, i(id) j(mnth) count if id=="" drop if id=="" cd $programs do monthwave93.do cd $tempdata sort id wave month save testm, replace * Core data local i=1 use $ids suseqnum suid panel month year /* */ hwgt fwgt swgt fnlwgt using $c`i', clear sort $ids save test, replace local i=`i'+1 while `i'>=2 & `i'<10 { use $ids suseqnum suid panel month year /* */ hwgt fwgt swgt fnlwgt using $c`i', clear sort $ids append using test sort $ids save test, replace local i=`i'+1 } use testi, clear merge id using test tab _merge rename _merge mtst1 sort id wave merge id wave using testw tab _merge rename _merge mtst2 sort id wave month merge id wave month using testm tab _merge rename _merge mtst3 drop if mtst3~=3 drop mtst* save test, replace erase testi.dta erase testw.dta erase testm.dta end capture program drop loop92 program define loop92 * Longitudinal data: create three files 1) by id; 2) by id wave; 3) by id wave month * id cd $rawdata use id suseqnum pp_entry pp_pnum pnlwgt fnlwgt92 fnlwgt93 fnlwgt94 /* */ varstrat using sipp92l1, clear cd $tempdata sort id save testi, replace * id wave cd $rawdata use id pp_int* using sipp92l1, clear cd $tempdata renpfix pp_int0 pp_int renpfix pp_int pp_intv sort id reshape long pp_intv, i(id) j(wave) sort id wave drop if wave==10 save testw, replace * id month cd $rawdata use $idr pp_mis* age* hh_add* using sipp92l1, clear cd $tempdata renpfix age_ age renpfix age0 age renpfix hh_add0 hh_add renpfix pp_mis0 pp_mis sort id reshape long hh_add pp_mis age, i(id) j(mnth) drop if mnth>=37 & mnth<=40 cd $programs do monthwave92.do cd $tempdata sort id wave month save testm, replace * Core data local i=1 use $ids suseqnum suid panel month year /* */ hwgt fwgt swgt fnlwgt using $c`i', clear sort $ids save test, replace local i=`i'+1 while `i'>=2 & `i'<10 { use $ids suseqnum suid panel month year /* */ hwgt fwgt swgt fnlwgt using $c`i', clear sort $ids append using test sort $ids save test, replace local i=`i'+1 } use testi, clear merge id using test tab _merge rename _merge mtst1 sort id wave merge id wave using testw tab _merge rename _merge mtst2 sort id wave month merge id wave month using testm tab _merge rename _merge mtst3 drop if mtst3~=3 drop mtst* save test, replace erase testi.dta erase testw.dta erase testm.dta end capture program drop loop91 program define loop91 * Longitudinal data: create three files 1) by id; 2) by id wave; 3) by id wave month * id cd $rawdata use id suseqnum pp_entry pp_pnum pnlwgt fnlwgt92 fnlwgt91 /* */ varstrat using sipp91l1, clear cd $tempdata sort id save testi, replace * id wave cd $rawdata use id pp_intv* using sipp91l1, clear cd $tempdata renpfix pp_intv pp_int renpfix pp_int pp_intv sort id reshape long pp_intv, i(id) j(wave) sort id wave drop if wave==10 save testw, replace * id month cd $rawdata use $idr pp_mis* age* hh_add* using sipp91l1, clear cd $tempdata renpfix age_ age renpfix age0 age renpfix hh_add0 hh_add renpfix pp_mis0 pp_mis sort id reshape long hh_add pp_mis age, i(id) j(mnth) drop if mnth>=37 & mnth<=40 cd $programs do monthwave91.do cd $tempdata sort id wave month save testm, replace * Core data local i=1 use $ids suseqnum suid panel month year /* */ hwgt fwgt swgt fnlwgt using $c`i', clear sort $ids save test, replace local i=`i'+1 while `i'>=2 & `i'<9 { use $ids suseqnum suid panel month year /* */ hwgt fwgt swgt fnlwgt using $c`i', clear sort $ids append using test sort $ids save test, replace local i=`i'+1 } use testi, clear merge id using test tab _merge rename _merge mtst1 sort id wave merge id wave using testw tab _merge rename _merge mtst2 sort id wave month merge id wave month using testm tab _merge rename _merge mtst3 drop if mtst3~=3 drop mtst* save test, replace erase testi.dta erase testw.dta erase testm.dta end capture program drop loop90 program define loop90 * Longitudinal data: create three files 1) by id; 2) by id wave; 3) by id wave month * id cd $rawdata use id suseqnum pp_entry pp_pnum pnlwgt fnlwgt90 fnlwgt91 /* */ varstrat using sipp90l1, clear cd $tempdata sort id save testi, replace * id wave cd $rawdata use id pp_intv* using sipp90l1, clear cd $tempdata renpfix pp_intv pp_int renpfix pp_int pp_intv sort id reshape long pp_intv, i(id) j(wave) sort id wave drop if wave==10 save testw, replace * id month cd $rawdata use $idr pp_mis* age* hh_add* using sipp90l1, clear cd $tempdata renpfix age_ age renpfix age0 age renpfix hh_add0 hh_add renpfix pp_mis0 pp_mis sort id reshape long hh_add pp_mis age, i(id) j(mnth) drop if mnth>=37 & mnth<=40 cd $programs do monthwave90.do cd $tempdata sort id wave month save testm, replace * Core data local i=1 use $ids suseqnum suid panel month year /* */ hwgt fwgt swgt fnlwgt using $c`i', clear sort $ids save test, replace local i=`i'+1 while `i'>=2 & `i'<9 { use $ids suseqnum suid panel month year /* */ hwgt fwgt swgt fnlwgt using $c`i', clear sort $ids append using test sort $ids save test, replace local i=`i'+1 } use testi, clear merge id using test tab _merge rename _merge mtst1 sort id wave merge id wave using testw tab _merge rename _merge mtst2 sort id wave month merge id wave month using testm tab _merge rename _merge mtst3 drop if mtst3~=3 drop mtst* save test, replace erase testi.dta erase testw.dta erase testm.dta end loop$p