set memory 500m use "/home/eva/CPS_QR/CPS6203_raw.dta", clear /* rename variables to more friendly names */ for @ in any region state popstat marstat year race: rename _@ @ rename _esr emp_stat rename _wkslyr weeksly rename _clslyr classly rename occlyr occly /* drop observations for children and for Armed Forces members, i.e. restrict sample to civilian adults */ keep if popstat==1 drop popstat /* for years with two samples, keep only one of them */ drop if year=="1988b" drop if year=="2001" replace year="2001" if year=="2001s" destring year, replace compress /* load the values of the personal consumption expenditure deflator for each year */ gen pce=20.016 if year==1962 replace pce=20.250 if year==1963 replace pce=20.484 if year==1964 replace pce=20.773 if year==1965 replace pce=21.079 if year==1966 replace pce=21.628 if year==1967 replace pce=22.168 if year==1968 replace pce=23.033 if year==1969 replace pce=24.077 if year==1970 replace pce=25.212 if year==1971 replace pce=26.292 if year==1972 replace pce=27.211 if year==1973 replace pce=28.687 if year==1974 replace pce=31.641 if year==1975 replace pce=34.225 if year==1976 replace pce=36.089 if year==1977 replace pce=38.475 if year==1978 replace pce=41.221 if year==1979 replace pce=44.868 if year==1980 replace pce=49.712 if year==1981 replace pce=54.097 if year==1982 replace pce=57.158 if year==1983 replace pce=59.598 if year==1984 replace pce=61.795 if year==1985 replace pce=63.920 if year==1986 replace pce=65.478 if year==1987 replace pce=67.972 if year==1988 replace pce=70.628 if year==1989 replace pce=73.708 if year==1990 replace pce=77.102 if year==1991 replace pce=80.056 if year==1992 replace pce=82.496 if year==1993 replace pce=84.468 if year==1994 replace pce=86.170 if year==1995 replace pce=88.151 if year==1996 replace pce=90.041 if year==1997 replace pce=91.788 if year==1998 replace pce=92.770 if year==1999 replace pce=94.300 if year==2000 replace pce=96.695 if year==2001 replace pce=98.649 if year==2002 replace pce=100.000 if year==2003 /* infer region variable from state variable for years with missing region data */ /* turn missing values into 0 for the region variable */ replace region=1 if state>=1 & state<=5 & ((year>=1968 & year<=1975) | year==1963) replace region=2 if state>=6 & state<=10 & ((year>=1968 & year<=1975) | year==1963) replace region=3 if state>=11 & state<=18 & ((year>=1968 & year<=1975) | year==1963) replace region=4 if state>=19 & state<=21 & ((year>=1968 & year<=1975) | year==1963) replace region=0 if region==. drop state /* infer hispanic variable from spanish ethnicity variable 1971 onwards */ /* hispanic is set to missing for years prior to 1971 */ gen byte hispanic=0 if year>=1971 replace hispanic=1 if _spneth<=7 & year>=1971 drop _spneth /* replace missing occupation and weight observations with 0 */ /* replace missing and not-in-smaple class of worker observations with 0 */ replace occly=0 if occly==. replace wgt=0 if wgt==. replace classly=0 if classly==. | classly==6 | classly==9 /* harmonize the definition of employment status by changing all unemployed to 3 */ /* infer employment status for 1994 from other monthly labor force status indicator */ replace emp_stat=3 if emp_stat==4 replace emp_stat=1 if mlr==1 & year==1994 replace emp_stat=2 if mlr==2 & year==1994 replace emp_stat=3 if (mlr==3 | mlr==4) & year==1994 replace emp_stat=7 if mlr>=5 & mlr<=7 & year==1994 drop mlr /* generate education group indicator 1992 onwards from original CPS variable that indicates highest grade/degree attained */ /* prior to 1991 use the recoded variable created by Unicon that indicates the highest grade completed */ /* to insure the least break at the time of the data collection switch, we categorize workers with 17 years of education as college grads */ gen byte educ=1 if grdatn<=38 & year>=1992 replace educ=2 if grdatn==39 & year>=1992 replace educ=3 if grdatn>=40 & grdatn<=42 & year>=1992 replace educ=4 if grdatn==43 & year>=1992 replace educ=5 if grdatn>43 & grdatn~=. & year>=1992 replace grdcom=1 if grdcom==6 replace grdcom=2 if grdcom==7 replace _educ=_educ+0.5 if grdcom==2 & year<=1991 replace educ=1 if _educ<=11.5 & year<=1991 replace educ=2 if _educ==12 & year<=1991 replace educ=3 if _educ>=12.5 & _educ<=15.5 & year<=1991 replace educ=4 if _educ>=16 & _educ<=17.5 & year<=1991 replace educ=5 if _educ>=18 & _educ~=. & year<=1991 drop grdatn _educ grdcom /* the variable wage_sample is 1 for observations that are in the sample from which we calculate mean wages, etc */ /* the variable emp_sample is 1 for observations that are in the sample from which we calculate employment statistics */ /* all variables are initially in both samples, then we make sample restriction choices later in the file */ gen byte wage_sample=1 gen byte emp_sample=1 gen byte week_sample=1 gen byte occ_sample=1 /* impose age restriction on wage and employment sample, note that since employment refers to last week, age is this year's age */ replace wage_sample=0 if age<23 | age>66 replace week_sample=0 if age<23 | age>66 replace emp_sample=0 if age<22 | age>65 replace occ_sample=0 if age<23 | age>66 /* the employment sample requires that employment status is observed */ replace emp_sample=0 if emp_stat==0 /* determine which observations represent full-time/full-year observations, only these should remain in the wage sample */ /* when changing the definition of full year replace 40 in the lines below by 48 */ replace weeksly=0 if weeksly==. replace ftpt=0 if ftpt==. | ftpt==5 | ftpt==9 gen byte ftfy=0 replace ftfy=1 if ftpt==2 & weeksly>=40 & year==1962 replace ftfy=1 if ftpt==1 & weeksly>=40 & year>=1963 & year<=1967 replace ftfy=1 if (ftpt==1 | ftpt==3) & weeksly>=40 & year>=1968 replace wage_sample=0 if ftfy==0 replace occ_sample=0 if ftfy==0 /*drop observations where the worker is working without pay */ /* or is self-employed */ replace wage_sample=0 if classly>=3 replace occ_sample=0 if classly>=3 /* harmonize wage observations so that they are always 0 when observation not in universe */ replace incwag=0 if incwag==99999 & year>=1968 & year<=1975 replace incwag=0 if incwag==. & year>=1962 & year<=1967 /* generate a variable indicating whether the observation was topcoded or not */ gen byte topcode=0 replace topcode=1 if incer1>200000 & year==2003 replace topcode=1 if incer1>150000 & year>=1996 & year<=2002 replace topcode=1 if incer1>=99999 & year>=1989 & year<=1995 replace topcode=1 if incwag>=99999 & year>=1985 & year<=1988 replace topcode=1 if incwag>=75000 & year>=1982 & year<=1984 replace topcode=1 if incwag>=50000 & year>=1968 & year<=1981 replace topcode=1 if incwag>=99900 & year>=1962 & year<=1967 /* replace topcoded wage observations by 1.75 the top-code value */ replace incwag=incwag*1.75 if topcode==1 & year<=1995 /* generate real annualized weekly wages */ rename incwag wage_total gen wage=wage_total/weeksly*52 if weeksly>0 /* annualize weekly wages to 52 weeks */ gen real_wage=wage/pce*100 /* do not include in the wage sample if annual real wage is less than a sixth of the real minimum wage ($1/hour), times 35 hours/week times 40 weeks */ replace wage_sample=0 if real_wage<35*40 /* do not include in the weeks sample if observation is not in the universe */ replace week_sample=0 if match~=0 & year==1962 replace week_sample=0 if match~=1 & year>=1963 & year<=1967 /* generate occupation dummies for phh and farm workers */ rename occly occ gen byte ph=0 replace ph=1 if occ==20 & year==1962 replace ph=1 if occ==21 & year>=1963 & year<=1967 replace ph=1 if occ>=801 & occ<=804 & year>=1968 & year<=1970 replace ph=1 if occ>=980 & occ<=986 & year>=1971 & year<=1982 replace ph=1 if occ>=403 & occ<=407 & year>=1983 & year<=2002 gen byte farmhand=0 replace farmhand=1 if occ==23 & year==1962 replace farmhand=1 if occ==24 & year>=1963 & year<=1967 replace farmhand=1 if occ>=901 & occ<=903 & year>=1968 & year<=1970 replace farmhand=1 if occ>=821 & occ<=823 & year>=1971 & year<=1982 replace farmhand=1 if occ==846 & year>=1971 & year<=1982 replace farmhand=1 if occ>=477 & occ<=479 & year>=1983 & year<=2002 gen byte farmer=0 replace farmer=1 if occ==6 & year==1962 replace farmer=1 if occ==7 & year>=1963 & year<=1967 replace farmer=1 if occ>=200 & occ<=222 & year>=1968 & year<=1970 replace farmer=1 if occ>=801 & occ<=806 & year>=1971 & year<=1982 replace farmer=1 if occ>=473 & occ<=476 & year>=1983 & year<=2002 /* generate occupation dummies for all workers */ gen byte occat=. /* 1983-2002 */ /* Managers & professionals */ replace occat=1 if occ>=1 & occ<=94 & year>=1983 & year<=2002 replace occat=1 if occ>=113 & occ<=154 & year>=1983 & year<=2002 replace occat=1 if occ>=166 & occ<=173 & year>=1983 & year<=2002 replace occat=1 if occ>=178 & occ<=202 & year>=1983 & year<=2002 replace occat=1 if occ>=229 & occ<=229 & year>=1983 & year<=2002 replace occat=1 if occ>=243 & occ<=243 & year>=1983 & year<=2002 /* White collar */ replace occat=2 if occ>=95 & occ<=112 & year>=1983 & year<=2002 replace occat=2 if occ>=155 & occ<=165 & year>=1983 & year<=2002 replace occat=2 if occ>=174 & occ<=177 & year>=1983 & year<=2002 replace occat=2 if occ>=203 & occ<=228 & year>=1983 & year<=2002 replace occat=2 if occ>=230 & occ<=242 & year>=1983 & year<=2002 replace occat=2 if occ>=244 & occ<=344 & year>=1983 & year<=2002 replace occat=2 if occ>=359 & occ<=402 & year>=1983 & year<=2002 /* Blue collar */ replace occat=3 if occ>=345 & occ<=358 & year>=1983 & year<=2002 replace occat=3 if occ>=403 & occ<=904 & year>=1983 & year<=2002 /* 1971-1982 */ /* Managers & professionals */ replace occat=1 if occ>=1 & occ<=21 & year>=1971 & year<=1982 replace occat=1 if occ>=23 & occ<=31 & year>=1971 & year<=1982 replace occat=1 if occ>=34 & occ<=63 & year>=1971 & year<=1982 replace occat=1 if occ>=65 & occ<=73 & year>=1971 & year<=1982 replace occat=1 if occ>=91 & occ<=99 & year>=1971 & year<=1982 replace occat=1 if occ>=102 & occ<=140 & year>=1971 & year<=1982 replace occat=1 if occ>=161 & occ<=161 & year>=1971 & year<=1982 replace occat=1 if occ>=170 & occ<=170 & year>=1971 & year<=1982 replace occat=1 if occ>=175 & occ<=195 & year>=1971 & year<=1982 replace occat=1 if occ>=201 & occ<=219 & year>=1971 & year<=1982 replace occat=1 if occ>=222 & occ<=225 & year>=1971 & year<=1982 replace occat=1 if occ>=227 & occ<=259 & year>=1971 & year<=1982 /* White collar */ replace occat=2 if occ>=22 & occ<=22 & year>=1971 & year<=1982 replace occat=2 if occ>=32 & occ<=33 & year>=1971 & year<=1982 replace occat=2 if occ>=64 & occ<=64 & year>=1971 & year<=1982 replace occat=2 if occ>=74 & occ<=90 & year>=1971 & year<=1982 replace occat=2 if occ>=100 & occ<=101 & year>=1971 & year<=1982 replace occat=2 if occ>=141 & occ<=160 & year>=1971 & year<=1982 replace occat=2 if occ>=162 & occ<=169 & year>=1971 & year<=1982 replace occat=2 if occ>=171 & occ<=174 & year>=1971 & year<=1982 replace occat=2 if occ>=196 & occ<=200 & year>=1971 & year<=1982 replace occat=2 if occ>=220 & occ<=220 & year>=1971 & year<=1982 replace occat=2 if occ>=260 & occ<=400 & year>=1971 & year<=1982 /* Blue collar */ replace occat=3 if occ>=221 & occ<=221 & year>=1971 & year<=1982 replace occat=3 if occ>=226 & occ<=226 & year>=1971 & year<=1982 replace occat=3 if occ>=401 & occ<=986 & year>=1971 & year<=1982 save "/home/eva/CPS_QR/Final/CPS6203.dta", replace