set more 1 /* File: 17th_pums_proc_1980.do Date: Jan 10, 2004 Desc: Prepares extract of 1980 Decennial Census PUMS 1% */ capture program drop rd1980 program define rd1980 version 7.0 * prepare basic state files from PUMSB1980 while "`1'"~="" { * * person records in 1980 PUMS don't have unique household identifier; * the following creates one using the procedure recommended by William * Gould in "Reading a hierarchical dataset with infile" (see: * http://www.columbia.edu/acis/eds/stat_pak/stata/hier.html) * * read household records * !cp "$d1980/pums80`1'.txt" "$d1980/PUMSBX.TXT" clear qui infile using "$do/17th_pums_h_1980.dct" if rectype=="H" gen long id=_n /* create id for subsequent merge with person records */ * replace apparently missing state codes if "`1'"=="AL" {replace state=1} if "`1'"=="AK" {replace state=2} if "`1'"=="AZ" {replace state=4} if "`1'"=="AR" {replace state=5} if "`1'"=="CA" {replace state=6} if "`1'"=="CO" {replace state=8} if "`1'"=="CT" {replace state=9} if "`1'"=="DE" {replace state=10} if "`1'"=="DC" {replace state=11} if "`1'"=="FL" {replace state=12} if "`1'"=="GA" {replace state=13} if "`1'"=="HI" {replace state=15} if "`1'"=="ID" {replace state=16} if "`1'"=="IL" {replace state=17} if "`1'"=="IN" {replace state=18} if "`1'"=="IA" {replace state=19} if "`1'"=="KS" {replace state=20} if "`1'"=="KY" {replace state=21} if "`1'"=="LA" {replace state=22} if "`1'"=="ME" {replace state=23} if "`1'"=="MD" {replace state=24} if "`1'"=="MA" {replace state=25} if "`1'"=="MI" {replace state=26} if "`1'"=="MN" {replace state=27} if "`1'"=="MS" {replace state=28} if "`1'"=="MO" {replace state=29} if "`1'"=="MT" {replace state=30} if "`1'"=="NE" {replace state=31} if "`1'"=="NV" {replace state=32} if "`1'"=="NH" {replace state=33} if "`1'"=="NJ" {replace state=34} if "`1'"=="NM" {replace state=35} if "`1'"=="NY" {replace state=36} if "`1'"=="NC" {replace state=37} if "`1'"=="ND" {replace state=38} if "`1'"=="OH" {replace state=39} if "`1'"=="OK" {replace state=40} if "`1'"=="OR" {replace state=41} if "`1'"=="PA" {replace state=42} if "`1'"=="RI" {replace state=44} if "`1'"=="SC" {replace state=45} if "`1'"=="SD" {replace state=46} if "`1'"=="TN" {replace state=47} if "`1'"=="TX" {replace state=48} if "`1'"=="UT" {replace state=49} if "`1'"=="VT" {replace state=50} if "`1'"=="VA" {replace state=51} if "`1'"=="WA" {replace state=53} if "`1'"=="WV" {replace state=54} if "`1'"=="WI" {replace state=55} if "`1'"=="WY" {replace state=56} if "`1'"=="PR" {replace state=72} if "`1'"=="XX" {replace state=99} * do "$do/17th_pums_h_label_1980.do" * drop rectype sort id save "$work/h_1980_temp_`1'", replace * * read individual records * clear qui infile using "$do/17th_pums_p_1980.dct" /* read HH and person records */ gen long id=1 if rectype=="H" replace id=sum(id) * do "$do/17th_pums_p_label_1980.do" * drop rectype sort id save "$work/p_1980_temp_`1'", replace * * attach household variables to individual records * merge id using "$work/h_1980_temp_`1'" assert rectype=="P" | rectype=="H" /* check */ assert _merge==2 | _merge==3 /* check */ drop if persons==0 /* eliminates vacant houses */ assert _merge==3 /* which should leave only correct matches */ drop _merge /* no longer needed */ sort id rename serialno sernum by id: egen serialno=min(sernum) /* assign HH serialno to person records */ drop if rectype=="H" /* leave only person records */ drop rectype id /* use PUMS serialno variable, not artificial id variable */ * tidy data capture drop hfiller* capture drop pfiller* compress * * save transformed state files * sort serialno save "$work/pums_1980_pre_`1'", replace * !rm "$d1980/PUMSBX.TXT" !rm "$work/p_1980_temp_`1'.dta" !rm "$work/h_1980_temp_`1'.dta" mac shift } end capture program drop all1980 program define all1980 version 7.0 * combine all variables in all state files from PUMSB1980 use "$work/pums_1980_pre_`1'", clear mac shift while "`1'"~="" { append using "$work/pums_1980_pre_`1'" mac shift } save "$work/pums_1980_pre_all", replace end capture program drop ap11980 program define ap11980 version 7.0 * combine selection of variables in all state files from PUMSB1980 use "$work/pums_1980_pre_`1'", clear mac shift while "`1'"~="" { append using "$work/pums_1980_pre_`1'" * drop allocation flags drop agqtype atenure avac1 avac2 avac3 avac4 acondo aunits1 aunits2 aaccess /* */ ayrbuilt astories aelevato arooms abedroom aplumbin akitchen abathroo /* */ awater asewage aaircond aheating afuelhea afuelwtr afuelcoo aautos atrucks /* */ atelepho ayrmoved aacre1 aacre2 afarm acommerc avalue aeleccos agascost /* */ awtrcost afuelcos atax ainsur amortg1 amortg2 amortg3 ataxincl aisnincl /* */ arent1 arelat1 arelat2 asex aage aqtrbirth amarital arace1 arace2 aspanish /* */ ancstry abirthpl acitizen aimmigr alang1 alang2 alang3 afertil atimesma /* */ aagemr awidowed aschool ayearsch afingrad aaf75 acoll75 awork75 amig751 /* */ amig752 atime ameans acarpool ariders adisabl1 adisabl2 adisabl3 avet1 /* */ avet2 ayearwrk alabor ahours aindustr aoccup aclass awork79 aweekw79 /* */ ahour79 aweeku79 aincome1 aincome2 aincome3 aincome4 aincome5 aincome6 /* */ aincome7 mac shift } save "$work/pums_1980_pre_all", replace end capture program drop apa1980 program define apa1980 version 7.0 * combine selection of variables in all state files from PUMSB1980 use serialno division state puma msapmsa persons gqinst tenure value /* */ rnsmocpi mortgag3 rgrapi rent1 units1 autos rhhfamtp sex relat1 /* */ rlabor r18undr r65over rhhinc rfaminc houswgt age yearsch marital lang1 /* */ english pob immigr citizen class industry occup week89 hour89 /* */ income1 income2 income3 income4 income5 income6 income7 income8 /* */ rpincome poverty mobility pwgt1 /* */ using "$work/pums_1980_pre_`1'", clear mac shift while "`1'"~="" { append using "$work/pums_1980_pre_`1'", nolabel keep serialno division state puma msapmsa persons gqinst tenure value /* */ rnsmocpi mortgag3 rgrapi rent1 units1 autos rhhfamtp sex relat1 /* */ rlabor r18undr r65over rhhinc rfaminc houswgt age yearsch marital lang1 /* */ english pob immigr citizen class industry occup week89 hour89 /* */ income1 income2 income3 income4 income5 income6 income7 income8 /* */ rpincome poverty mobility pwgt1 mac shift } save "$work/pums_1980_pre_half_a", replace end capture program drop apb1980 program define apb1980 version 7.0 * combine selection of variables in all state files from PUMSB1980 use serialno division state puma msapmsa persons gqinst tenure value /* */ rnsmocpi mortgag3 rgrapi rent1 units1 autos rhhfamtp sex relat1 /* */ rlabor r18undr r65over rhhinc rfaminc houswgt age yearsch marital lang1 /* */ english pob immigr citizen class industry occup week89 hour89 /* */ income1 income2 income3 income4 income5 income6 income7 income8 /* */ rpincome poverty mobility pwgt1 /* */ using "$work/pums_1980_pre_`1'", clear mac shift while "`1'"~="" { append using "$work/pums_1980_pre_`1'", nolabel keep serialno division state puma msapmsa persons gqinst tenure value /* */ rnsmocpi mortgag3 rgrapi rent1 units1 autos rhhfamtp sex relat1 /* */ rlabor r18undr r65over rhhinc rfaminc houswgt age yearsch marital lang1 /* */ english pob immigr citizen class industry occup week89 hour89 /* */ income1 income2 income3 income4 income5 income6 income7 income8 /* */ rpincome poverty mobility pwgt1 mac shift } save "$work/pums_1980_pre_half_b", replace end capture program drop apc1980 program define apc1980 version 7.0 use "$work/pums_1980_pre_half_a", clear append using "$work/pums_1980_pre_half_b", nolabel save "$work/pums_1980_pre_all", replace end /* program switches */ /* read raw data */ rd1980 AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME /* */ MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA /* PR */ RI SC SD TN TX /* */ UT VA VT WA WI WV WY XX /* combine all variables in all state files (if RAM is sufficiently large) */ all1980 AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME /* */ MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA /* PR */ RI SC SD TN /* */ TX UT VA VT WA WI WV WY XX /* /* combine main variables in all state files */ apa1980 AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME /* */ MI MN MO MS MT apb1980 NC ND NE NH NJ NM NV NY OH OK OR PA /* PR */ RI SC SD TN TX UT VA /* */ VT WA WI WV WY 99 apc1980 */ /* Copyright 2005 Sarah Gammage and John Schmitt This program and all programs referenced in it are free software. You can redistribute the program or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */