set more 1 clear set mem 500m /* File: cepr_org_extracts.do Date: Nov 14, 2005, CEPR ORG Version 1.0 Desc: Creates extracts from CPS Basic files Note: See copyright notice at end of program */ capture program drop kosit program define kosit version 5.0 local dictno `1' * prepare data for subsequent merger by year rename hrhhid hhid rename huhhnum hhnum rename pulineno lineno drop if lineno==-1 keep if hrmis==4 | hrmis==8 keep if 16<=peage & peage<100 if `dictno'==1 | `dictno'==2 { rename peern ptern rename puern2 ptern2 rename prernwa pternwa rename perrp proldrrp } if `dictno'==3 { rename pternhly prernhly } sort hhid hhnum lineno hrlonglk keep hhid hhnum lineno hrlonglk /* */ pehract1 pehract2 pehractt peernhro peernrt peernhry peernuot /* */ ptern ptern2 pternwa ptot /* */ prhrusl pehrusl1 pehrusl2 pehrftpt pehruslt prpthrs prptrea prernhly /* */ pthr ptwk hrmonth hrmis peage pesex gestcen /* */ hurespli proldrrp puslfprx order hhid hhnum lineno hrlonglk /* */ pehract1 pehract2 pehractt peernhro peernrt peernhry peernuot /* */ ptern ptern2 pternwa ptot /* */ prhrusl pehrusl1 pehrusl2 pehrftpt pehruslt prpthrs prptrea prernhly /* */ pthr ptwk hrmonth hrmis peage pesex gestcen /* */ hurespli proldrrp puslfprx end capture program drop b1994 program define b1994 version 7.0 * process 1994 Basic CPS cd $locbas cd 1994 !$unzip cpsb94.zip while "`1'"~="" { clear if $gnulin==1 { local dat_name "$locbas/1994/cpsb94x.txt" local dct_name "$locbdo/cpsb_jan94_aug95.dct" } if $gnulin==0 { local dat_name "$locbas\1994\cpsb94x.txt" local dct_name "$locbdo\cpsb_jan94_aug95.dct" } cd $locbas cd 1994 !$copy cpsb94`1' cpsb94x.txt qui infile using "`dct_name'", using("`dat_name'") clear local dictno=1 replace hryear=hryear+1900 /* make y2k friendly */ kosit `dictno' cd $locbas cd 1994 save cpsb94`1'x.dta, replace !$erase cpsb94`1' mac shift } * combine cd $locbas cd 1994 use cpsb9401x.dta, clear local month=2 while `month'<=9 { append using cpsb940`month'x.dta local month=`month'+1 } while `month' <=12 { append using cpsb94`month'x.dta local month=`month'+1 } save cpsb1994x.dta, replace * tidy !$erase cpsb94x.txt !$erase cpsb94*.dta end capture program drop b1995 program define b1995 version 7.0 * process 1995 Basic CPS cd $locbas cd 1995 !$unzip cpsb95.zip while "`1'"~="" { if `1'<=8 { * use Jan 1994 dictionary through Aug 1995 if $gnulin==1 { local dat_name "$locbas/1994/cpsb94x.txt" local dct_name "$locbdo/cpsb_jan94_aug95.dct" } if $gnulin==0 { local dat_name "$locbas\1994\cpsb94x.txt" local dct_name "$locbdo\cpsb_jan94_aug95.dct" } cd $locbas cd 1995 !$copy cpsb95`1' "`dat_name'" clear qui infile using "`dct_name'", using("`dat_name'") clear local dictno=1 } if 9<=`1' { * use new dictionary Sep 1995 through Dec 1997 if $gnulin==1 { local dat_name "$locbas/1995/cpsb95x.txt" local dct_name "$locbdo/cpsb_sep95_dec97.dct" } if $gnulin==0 { local dat_name "$locbas\1995\cpsb95x.txt" local dct_name "$locbdo\cpsb_sep95_dec97.dct" } cd $locbas cd 1995 !$copy cpsb95`1' cpsb95x.txt clear qui infile using "`dct_name'", using("`dat_name'") clear local dictno=2 } replace hryear=hryear+1900 /* make y2k friendly */ kosit `dictno' cd $locbas cd 1995 save cpsb95`1'x.dta, replace !$erase cpsb95`1' mac shift } * combine cd $locbas cd 1995 use cpsb9501x.dta, clear local month=2 while `month'<=9 { cd $locbas cd 1995 append using cpsb950`month'x.dta local month=`month'+1 } while `month' <=12 { cd $locbas cd 1995 append using cpsb95`month'x.dta local month=`month'+1 } cd $locbas cd 1995 save cpsb1995x.dta,replace * tidy cd $locbas cd 1994 !$erase cpsb94x.txt cd $locbas cd 1995 !$erase cpsb95x.txt !$erase cpsb95*.dta end capture program drop b1996 program define b1996 version 7.0 * process 1996 Basic CPS cd $locbas cd 1996 !$unzip cpsb96.zip while "`1'"~="" { * use new dictionary Sep 1995 through Dec 1997 if $gnulin==1 { local dat_name "$locbas/1995/cpsb95x.txt" local dct_name "$locbdo/cpsb_sep95_dec97.dct" } if $gnulin==0 { local dat_name "$locbas\1995\cpsb95x.txt" local dct_name "$locbdo\cpsb_sep95_dec97.dct" } cd $locbas cd 1996 !$copy cpsb96`1' "`dat_name'" clear qui infile using "`dct_name'", using("`dat_name'") clear local dictno=2 replace hryear=hryear+1900 /* make y2k friendly */ kosit `dictno' cd $locbas cd 1996 save cpsb96`1'x.dta, replace !$erase cpsb96`1' mac shift } * combine cd $locbas cd 1996 use cpsb9601x.dta, clear local month=2 while `month'<=9 { append using cpsb960`month'x.dta local month=`month'+1 } while `month' <=12 { append using cpsb96`month'x.dta local month=`month'+1 } save cpsb1996x.dta,replace * tidy cd $locbas cd 1995 !$erase cpsb95x.txt cd $locbas cd 1996 !$erase cpsb96*.dta end capture program drop b1997 program define b1997 version 7.0 * process 1997 Basic CPS cd $locbas cd 1997 !$unzip cpsb97.zip while "`1'"~="" { * use new dictionary Sep 1995 through Dec 1997 if $gnulin==1 { local dat_name "$locbas/1995/cpsb95x.txt" local dct_name "$locbdo/cpsb_sep95_dec97.dct" } if $gnulin==0 { local dat_name "$locbas\1995\cpsb95x.txt" local dct_name "$locbdo\cpsb_sep95_dec97.dct" } cd $locbas cd 1997 !$copy cpsb97`1' "`dat_name'" clear qui infile using "`dct_name'", using("`dat_name'") clear local dictno=2 replace hryear=hryear+1900 /* make y2k friendly */ kosit `dictno' cd $locbas cd 1997 save cpsb97`1'x.dta, replace !$erase cpsb97`1' mac shift } * combine cd $locbas cd 1997 use cpsb9701x.dta, clear local month=2 while `month'<=9 { cd $locbas cd 1997 append using cpsb970`month'x.dta local month=`month'+1 } while `month' <=12 { cd $locbas cd 1997 append using cpsb97`month'x.dta local month=`month'+1 } cd $locbas cd 1997 save cpsb1997x.dta,replace * tidy cd $locbas cd 1995 !$erase cpsb95x.txt cd $locbas cd 1997 !$erase cpsb97*.dta end capture program drop b1998 program define b1998 version 7.0 * process 1998 Basic CPS cd $locbas cd 1998 !$unzip cpsb98.zip while "`1'"~="" { * use new dictionary Jan 1998 through ? if $gnulin==1 { local dat_name "$locbas/1998/cpsb98x.txt" local dct_name "$locbdo/cpsb_jan98_dec02.dct" } if $gnulin==0 { local dat_name "$locbas\1998\cpsb98x.txt" local dct_name "$locbdo\cpsb_jan98_dec02.dct" } cd $locbas cd 1998 !$copy cpsb98`1' "`dat_name'" clear qui infile using "`dct_name'", using("`dat_name'") clear local dictno=3 kosit `dictno' cd $locbas cd 1998 save cpsb98`1'x.dta, replace !$erase cpsb98`1' mac shift } * combine cd $locbas cd 1998 use cpsb9801x.dta, clear local month=2 while `month'<=9 { cd $locbas cd 1998 append using cpsb980`month'x.dta local month=`month'+1 } while `month' <=12 { cd $locbas cd 1998 append using cpsb98`month'x.dta local month=`month'+1 } cd $locbas cd 1998 save cpsb1998x.dta,replace * tidy !$erase cpsb98x.txt !$erase cpsb98*.dta end capture program drop b1999 program define b1999 version 7.0 * process 1999 Basic CPS cd $locbas cd 1999 !$unzip cpsb99.zip while "`1'"~="" { * use new dictionary Jan 1998 through ? if $gnulin==1 { local dat_name "$locbas/1998/cpsb98x.txt" local dct_name "$locbdo/cpsb_jan98_dec02.dct" } if $gnulin==0 { local dat_name "$locbas\1998\cpsb98x.txt" local dct_name "$locbdo\cpsb_jan98_dec02.dct" } cd $locbas cd 1999 !$copy cpsb99`1' "`dat_name'" clear qui infile using "`dct_name'", using("`dat_name'") clear local dictno=3 kosit `dictno' cd $locbas cd 1999 save cpsb99`1'x.dta, replace !$erase cpsb99`1' mac shift } * combine cd $locbas cd 1999 use cpsb9901x.dta, clear local month=2 while `month'<=9 { cd $locbas cd 1999 append using cpsb990`month'x.dta local month=`month'+1 } while `month' <=12 { cd $locbas cd 1999 append using cpsb99`month'x.dta local month=`month'+1 } cd $locbas cd 1999 save cpsb1999x.dta,replace * tidy cd $locbas cd 1998 !$erase "$locbas\1998\cpsb98x.txt" cd $locbas cd 1999 !$erase "$locbas\1999\cpsb99*.dta" end capture program drop b2000 program define b2000 version 7.0 * process 2000 Basic CPS cd $locbas cd 2000 !$unzip cpsb00.zip while "`1'"~="" { * use new dictionary Jan 1998 through ? if $gnulin==1 { local dat_name "$locbas/1998/cpsb98x.txt" local dct_name "$locbdo/cpsb_jan98_dec02.dct" } if $gnulin==0 { local dat_name "$locbas\1998\cpsb98x.txt" local dct_name "$locbdo\cpsb_jan98_dec02.dct" } cd $locbas cd 2000 !$copy cpsb00`1' "`dat_name'" clear qui infile using "`dct_name'", using("`dat_name'") clear local dictno=3 kosit `dictno' cd $locbas cd 2000 save cpsb00`1'x.dta, replace !$erase cpsb00`1' mac shift } * combine cd $locbas cd 2000 use cpsb0001x.dta, clear local month=2 while `month'<=9 { cd $locbas cd 2000 append using cpsb000`month'x.dta local month=`month'+1 } while `month' <=12 { cd $locbas cd 2000 append using cpsb00`month'x.dta local month=`month'+1 } cd $locbas cd 2000 save cpsb2000x.dta, replace * tidy cd $locbas cd 1998 !$erase cpsb98x.txt cd $locbas cd 2000 !$erase cpsb00*.dta end capture program drop b2001 program define b2001 version 7.0 * process 2001 Basic CPS cd $locbas cd 2001 !$unzip cpsb01.zip while "`1'"~="" { * use new dictionary Jan 1998 through ? if $gnulin==1 { local dat_name "$locbas/1998/cpsb98x.txt" local dct_name "$locbdo/cpsb_jan98_dec02.dct" } if $gnulin==0 { local dat_name "$locbas\1998\cpsb98x.txt" local dct_name "$locbdo\cpsb_jan98_dec02.dct" } cd $locbas cd 2001 !$copy cpsb01`1' "`dat_name'" clear qui infile using "`dct_name'", using("`dat_name'") clear local dictno=3 kosit `dictno' cd $locbas cd 2001 save cpsb01`1'x.dta, replace ! erase cpsb01`1' mac shift } * combine cd $locbas cd 2001 use cpsb0101x.dta, clear local month=2 while `month'<=9 { cd $locbas cd 2001 append using cpsb010`month'x.dta local month=`month'+1 } while `month' <=12 { cd $locbas cd 2001 append using cpsb01`month'x.dta local month=`month'+1 } cd $locbas cd 2001 save cpsb2001x.dta,replace * tidy cd $locbas cd 1998 !$erase cpsb98x.txt cd $locbas cd 2001 !$erase cpsb01*.dta end capture program drop b2002 program define b2002 version 7.0 * process 2002 Basic CPS cd $locbas cd 2002 !$unzip cpsb02.zip while "`1'"~="" { * use new dictionary Jan 1998 through ? if $gnulin==1 { local dat_name "$locbas/1998/cpsb98x.txt" local dct_name "$locbdo/cpsb_jan98_dec02.dct" } if $gnulin==0 { local dat_name "$locbas\1998\cpsb98x.txt" local dct_name "$locbdo\cpsb_jan98_dec02.dct" } cd $locbas cd 2002 !$copy cpsb02`1' "`dat_name'" clear qui infile using "`dct_name'", using("`dat_name'") clear local dictno=3 kosit `dictno' cd $locbas cd 2002 save cpsb02`1'x.dta, replace !$erase cpsb02`1' mac shift } * combine cd $locbas cd 2002 use cpsb0201x.dta, clear local month=2 while `month'<=9 { cd $locbas cd 2002 append using cpsb020`month'x.dta local month=`month'+1 } while `month' <=12 { cd $locbas cd 2002 append using cpsb02`month'x.dta local month=`month'+1 } cd $locbas cd 2002 save cpsb2002x.dta,replace * tidy cd $locbas cd 1998 !$erase cpsb98x.txt cd $locbas cd 2002 !$erase cpsb02*.dta end local allmos "01 02 03 04 05 06 07 08 09 10 11 12" * for YEAR in num 1994/2002 : bYEAR `allmos' forvalues i=1994/2002 { b`i' `allmos' } /* Copyright 2003 CEPR and John Schmitt This file is part of the cepr_org_master.do program. This file 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. */