---------------------------------------------------------------------------------------------
       log:  /volumes/ddisk/bgh/programs/wage_mf_ft_smsa.log
  log type:  text
 opened on:  13 Jul 2011, 08:39:38

. *THIS FILE ESTIMATES THE INVERSE ELASTICITY OF SUBSTITUTION FOR NATIVES AND IMMIGRANTS USIN
> G A PREFERRED SPECIFICATION;
. *18-64, POSITIVE HOURS WORKED, CORRECT DEFINITION OF IMMIGRANTS, EDUCREC FOR EDUCATION, ADJ
> UST FOR TOP CODING;
. *ESTIMATE EITHER MEN ONLY OR MEN AND WOMEN AND WITH INCWAGE;
. use /volumes/ddisk/ipums2/ipums80.dta, clear;

. generate byte imm=(citizen==2 | citizen==3);

. drop if wkswork1==0;
(1833748 observations deleted)

. *generate pdeflator=1.85;
. *REPLACE WITH OP DEFLATOR;
. generate pdeflator=2.314;

. drop if incwage==0 | incwage==999999;
(315819 observations deleted)

. replace incwage=75000*1.5 if incwage==75000;
(20226 real changes made)

. replace incbus=75000*1.5 if incbus==75000;
(1758 real changes made)

. replace incfarm=75000*1.5 if incfarm==75000;
(138 real changes made)

. *gen incearn=incwage+incbus+incfarm;
. generate weeks=wkswork1;

. generate hours=uhrswork;

. *SELECT FULL-TIME WORKERS;
. drop if weeks<40;
(1384639 observations deleted)

. drop if hours<35;
(471785 observations deleted)

. * DEFINE SAMPLE RESTRICTIONS, COMMON VARIABLES;
. do /volumes/ddisk/bgh/programs/restriction_wage_mf_smsa.do;

. #delimit ;
delimiter now ;
. *THESE ARE THE PREFERRED RESTRICTIONS FOR WAGE AND SALARY SAMPLE;
. generate perwt2=perwt;

. replace perwt=perwt*hours*weeks/2000;
perwt was byte now float
(3189474 real changes made)

. *COMMON RESTRICTIONS AND VARIABLE DEFINITIONS ACROSS SPECIFICATIONS;
. *IN SPECIFICATION 1 PROGRAM, OP USE 18 AGE CUTOFF;
. *IN OTHER PROGRAMS, OP USE 17 AGE CUTOFF;
. *DROPS SELF-EMPLOYED SO CORRECT SAMPLE OF WAGE & SALARY WORKERS;
. *keep if sex==1;
. drop if gq==0 | gq==3 | gq==4;
(36300 observations deleted)

.  drop if age<18 | age>64;
(22290 observations deleted)

. keep if classwkrd>=20 & classwkrd<=28;
(121897 observations deleted)

. rename perwt weight;

. rename perwt2 perwt;

. *NOTE THAT NEW IPUMS DOESN'T HAVE OLD EDUCATION CODING, SO HAD TO RECODE;
. *generate byte edcode=1*(educrec<=6) + 2*(educrec==7) + 3*(educrec==8) + 4*(educrec==9);
. generate byte edcode=1*(educ<=5) + 2*(educ==6) + 3*(educ>=7 & educ<=9) + 4*(educ==10 | educ
> ==11);

. generate exper=age-17 if edcode==1;
(2522508 missing values generated)

. replace exper=age-19 if edcode==2;
(1302693 real changes made)

. replace exper=age-21 if edcode==3;
(613686 real changes made)

. replace exper=age-23 if edcode==4;
(606129 real changes made)

. drop if exper<1 | exper>40;
(249814 observations deleted)

. generate expcode=1*(exper>=1 & exper<=5) + 2*(exper>=6 & exper<=10) + 3*(exper>=11 & exper<
> =15) + 4*(exper>=16 & exper<=20)
>                 +5*(exper>=21 & exper<=25) + 6*(exper>=26 & exper<=30) + 7*(exper>=31 & exp
> er<=35) + 8*(exper>=36 & exper<=40);

. replace incearn=incearn*(pdeflator);
(0 real changes made)

. replace incwage=incwage*(pdeflator);
incwage was long now double
(2925198 real changes made)

. generate weekly=(incwage/weeks);

. generate annual=(incwage);

. generate wage=incwage/(weeks*hours);

. generate lweekly=log(weekly);

. *NOTE THAT MEAN EARNINGS ARE WEIGHTED BY HOURS WORKED;
. generate smsa=int(metaread/10);

. drop if smsa==0;
(807839 observations deleted)

. summ smsa;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        smsa |   2117359    452.3766    248.8469          4        932

. 
end of do-file

. collapse (mean) lweekly weekly (count) sizew=weight (rawsum) sumweight=weight
>         (sd) slweekly=lweekly sweekly=weekly [aw=weight], by(imm smsa edcode);

. generate survey=1980;

. sort survey edcode;

. save /volumes/ddisk/data/rep80.dta, replace;
file /volumes/ddisk/data/rep80.dta saved

. use /volumes/ddisk/ipums2/ipums90.dta, clear;

. generate byte imm=(citizen==2 | citizen==3);

. drop if wkswork1==0;
(1666543 observations deleted)

. *generate pdeflator=1.22;
. *REPLACE WITH OP DEFLATOR;
. generate pdeflator=1.344;

. drop if incwage==0 | incwage==999999;
(392355 observations deleted)

. generate weeks=wkswork1;

. generate hours=uhrswork;

. *SELECT FULL-TIME WORKERS;
. drop if weeks<40;
(1419991 observations deleted)

. drop if hours<35;
(601231 observations deleted)

. * DEFINE SAMPLE RESTRICTIONS, COMMON VARIABLES;
. do /volumes/ddisk/bgh/programs/restriction_wage_mf_smsa.do;

. #delimit ;
delimiter now ;
. *THESE ARE THE PREFERRED RESTRICTIONS FOR WAGE AND SALARY SAMPLE;
. generate perwt2=perwt;

. replace perwt=perwt*hours*weeks/2000;
perwt was int now float
(3814648 real changes made)

. *COMMON RESTRICTIONS AND VARIABLE DEFINITIONS ACROSS SPECIFICATIONS;
. *IN SPECIFICATION 1 PROGRAM, OP USE 18 AGE CUTOFF;
. *IN OTHER PROGRAMS, OP USE 17 AGE CUTOFF;
. *DROPS SELF-EMPLOYED SO CORRECT SAMPLE OF WAGE & SALARY WORKERS;
. *keep if sex==1;
. drop if gq==0 | gq==3 | gq==4;
(36103 observations deleted)

.  drop if age<18 | age>64;
(20679 observations deleted)

. keep if classwkrd>=20 & classwkrd<=28;
(168009 observations deleted)

. rename perwt weight;

. rename perwt2 perwt;

. *NOTE THAT NEW IPUMS DOESN'T HAVE OLD EDUCATION CODING, SO HAD TO RECODE;
. *generate byte edcode=1*(educrec<=6) + 2*(educrec==7) + 3*(educrec==8) + 4*(educrec==9);
. generate byte edcode=1*(educ<=5) + 2*(educ==6) + 3*(educ>=7 & educ<=9) + 4*(educ==10 | educ
> ==11);

. generate exper=age-17 if edcode==1;
(3330113 missing values generated)

. replace exper=age-19 if edcode==2;
(1317810 real changes made)

. replace exper=age-21 if edcode==3;
(1124724 real changes made)

. replace exper=age-23 if edcode==4;
(887579 real changes made)

. drop if exper<1 | exper>40;
(208711 observations deleted)

. generate expcode=1*(exper>=1 & exper<=5) + 2*(exper>=6 & exper<=10) + 3*(exper>=11 & exper<
> =15) + 4*(exper>=16 & exper<=20)
>                 +5*(exper>=21 & exper<=25) + 6*(exper>=26 & exper<=30) + 7*(exper>=31 & exp
> er<=35) + 8*(exper>=36 & exper<=40);

. replace incearn=incearn*(pdeflator);
incearn was long now double
(3538809 real changes made)

. replace incwage=incwage*(pdeflator);
incwage was long now double
(3538853 real changes made)

. generate weekly=(incwage/weeks);

. generate annual=(incwage);

. generate wage=incwage/(weeks*hours);

. generate lweekly=log(weekly);

. *NOTE THAT MEAN EARNINGS ARE WEIGHTED BY HOURS WORKED;
. generate smsa=int(metaread/10);

. drop if smsa==0;
(1124674 observations deleted)

. summ smsa;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        smsa |   2414179    458.4156    253.0236          4        936

. 
end of do-file

. collapse (mean) lweekly weekly (count) sizew=weight (rawsum) sumweight=weight
>         (sd) slweekly=lweekly sweekly=weekly [aw=weight], by(imm smsa edcode);

. generate survey=1990;

. sort survey edcode;

. save /volumes/ddisk/data/rep90, replace;
file /volumes/ddisk/data/rep90.dta saved

. use /volumes/ddisk/ipums2/ipums00.dta, clear;

. generate byte imm=(citizen==2 | citizen==3);

. drop if wkswork1==0;
(1930814 observations deleted)

. *THIS IS ALSO THE BASE YEAR WITH OP DEFLATOR;
. generate pdeflator=1;

. drop if incwage==0 | incwage==999999;
(411812 observations deleted)

. generate weeks=wkswork1;

. generate hours=uhrswork;

. *SELECT FULL-TIME WORKERS;
. drop if weeks<40;
(1388286 observations deleted)

. drop if hours<35;
(701516 observations deleted)

. * DEFINE SAMPLE RESTRICTIONS, COMMON VARIABLES;
. do /volumes/ddisk/bgh/programs/restriction_wage_mf_smsa.do;

. #delimit ;
delimiter now ;
. *THESE ARE THE PREFERRED RESTRICTIONS FOR WAGE AND SALARY SAMPLE;
. generate perwt2=perwt;

. replace perwt=perwt*hours*weeks/2000;
perwt was int now float
(4486343 real changes made)

. *COMMON RESTRICTIONS AND VARIABLE DEFINITIONS ACROSS SPECIFICATIONS;
. *IN SPECIFICATION 1 PROGRAM, OP USE 18 AGE CUTOFF;
. *IN OTHER PROGRAMS, OP USE 17 AGE CUTOFF;
. *DROPS SELF-EMPLOYED SO CORRECT SAMPLE OF WAGE & SALARY WORKERS;
. *keep if sex==1;
. drop if gq==0 | gq==3 | gq==4;
(42874 observations deleted)

.  drop if age<18 | age>64;
(19198 observations deleted)

. keep if classwkrd>=20 & classwkrd<=28;
(202088 observations deleted)

. rename perwt weight;

. rename perwt2 perwt;

. *NOTE THAT NEW IPUMS DOESN'T HAVE OLD EDUCATION CODING, SO HAD TO RECODE;
. *generate byte edcode=1*(educrec<=6) + 2*(educrec==7) + 3*(educrec==8) + 4*(educrec==9);
. generate byte edcode=1*(educ<=5) + 2*(educ==6) + 3*(educ>=7 & educ<=9) + 4*(educ==10 | educ
> ==11);

. generate exper=age-17 if edcode==1;
(3995232 missing values generated)

. replace exper=age-19 if edcode==2;
(1766853 real changes made)

. replace exper=age-21 if edcode==3;
(1040210 real changes made)

. replace exper=age-23 if edcode==4;
(1188169 real changes made)

. drop if exper<1 | exper>40;
(199520 observations deleted)

. generate expcode=1*(exper>=1 & exper<=5) + 2*(exper>=6 & exper<=10) + 3*(exper>=11 & exper<
> =15) + 4*(exper>=16 & exper<=20)
>                 +5*(exper>=21 & exper<=25) + 6*(exper>=26 & exper<=30) + 7*(exper>=31 & exp
> er<=35) + 8*(exper>=36 & exper<=40);

. replace incearn=incearn*(pdeflator);
(0 real changes made)

. replace incwage=incwage*(pdeflator);
(0 real changes made)

. generate weekly=(incwage/weeks);

. generate annual=(incwage);

. generate wage=incwage/(weeks*hours);

. generate lweekly=log(weekly);

. *NOTE THAT MEAN EARNINGS ARE WEIGHTED BY HOURS WORKED;
. generate smsa=int(metaread/10);

. drop if smsa==0;
(1134799 observations deleted)

. summ smsa;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        smsa |   3055321    457.9624    254.0282          4        936

. 
end of do-file

. collapse (mean) lweekly weekly (count) sizew=weight (rawsum) sumweight=weight
>         (sd) slweekly=lweekly sweekly=weekly [aw=weight], by(imm smsa edcode);

. generate survey=2000;

. sort survey edcode;

. save /volumes/ddisk/data/rep00.dta, replace;
file /volumes/ddisk/data/rep00.dta saved

. use /volumes/ddisk/ipumsacs/data/acs.dta, clear;

. keep if year>=2005 & year<=2007;
(5211120 observations deleted)

. replace perwt=perwt/3;
perwt was int now float
(5755921 real changes made)

. generate byte imm=(citizen==2 | citizen==3);

. drop if wkswork1==0;
(1226408 observations deleted)

. *generate pdeflator=0.85;
. *REPLACE WITH OP DEFLATOR;
. generate pdeflator=0.853;

. drop if incwage==0 | incwage==999999;
(286393 observations deleted)

. generate weeks=wkswork1;

. generate hours=uhrswork;

. *SELECT FULL-TIME WORKERS;
. drop if weeks<40;
(873482 observations deleted)

. drop if hours<35;
(476626 observations deleted)

. * DEFINE SAMPLE RESTRICTIONS, COMMON VARIABLES;
. do /volumes/ddisk/bgh/programs/restriction_wage_mf_smsa.do;

. #delimit ;
delimiter now ;
. *THESE ARE THE PREFERRED RESTRICTIONS FOR WAGE AND SALARY SAMPLE;
. generate perwt2=perwt;

. replace perwt=perwt*hours*weeks/2000;
(2804093 real changes made)

. *COMMON RESTRICTIONS AND VARIABLE DEFINITIONS ACROSS SPECIFICATIONS;
. *IN SPECIFICATION 1 PROGRAM, OP USE 18 AGE CUTOFF;
. *IN OTHER PROGRAMS, OP USE 17 AGE CUTOFF;
. *DROPS SELF-EMPLOYED SO CORRECT SAMPLE OF WAGE & SALARY WORKERS;
. *keep if sex==1;
. drop if gq==0 | gq==3 | gq==4;
(13046 observations deleted)

.  drop if age<18 | age>64;
(17260 observations deleted)

. keep if classwkrd>=20 & classwkrd<=28;
(149322 observations deleted)

. rename perwt weight;

. rename perwt2 perwt;

. *NOTE THAT NEW IPUMS DOESN'T HAVE OLD EDUCATION CODING, SO HAD TO RECODE;
. *generate byte edcode=1*(educrec<=6) + 2*(educrec==7) + 3*(educrec==8) + 4*(educrec==9);
. generate byte edcode=1*(educ<=5) + 2*(educ==6) + 3*(educ>=7 & educ<=9) + 4*(educ==10 | educ
> ==11);

. generate exper=age-17 if edcode==1;
(2530973 missing values generated)

. replace exper=age-19 if edcode==2;
(981123 real changes made)

. replace exper=age-21 if edcode==3;
(646869 real changes made)

. replace exper=age-23 if edcode==4;
(902981 real changes made)

. drop if exper<1 | exper>40;
(140395 observations deleted)

. generate expcode=1*(exper>=1 & exper<=5) + 2*(exper>=6 & exper<=10) + 3*(exper>=11 & exper<
> =15) + 4*(exper>=16 & exper<=20)
>                 +5*(exper>=21 & exper<=25) + 6*(exper>=26 & exper<=30) + 7*(exper>=31 & exp
> er<=35) + 8*(exper>=36 & exper<=40);

. replace incearn=incearn*(pdeflator);
incearn was long now double
(2572989 real changes made)

. replace incwage=incwage*(pdeflator);
incwage was long now double
(2572989 real changes made)

. generate weekly=(incwage/weeks);

. generate annual=(incwage);

. generate wage=incwage/(weeks*hours);

. generate lweekly=log(weekly);

. *NOTE THAT MEAN EARNINGS ARE WEIGHTED BY HOURS WORKED;
. generate smsa=int(metaread/10);

. drop if smsa==0;
(644487 observations deleted)

. summ smsa;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        smsa |   1928502    457.3816    255.1852          4        936

. 
end of do-file

. collapse (mean) lweekly weekly (count) sizew=weight (rawsum) sumweight=weight
>         (sd) slweekly=lweekly sweekly=weekly [aw=weight], by(imm smsa edcode);

. gen survey=2006;

. sort survey edcode;

. save /volumes/ddisk/data/rep06.dta, replace;
file /volumes/ddisk/data/rep06.dta saved

. *POOL DATA ACROSS YEARS;
. use /volumes/ddisk/data/rep80.dta;

. append using /volumes/ddisk/data/rep90.dta;

. append using /volumes/ddisk/data/rep00.dta;

. append using /volumes/ddisk/data/rep06.dta;

. save /volumes/ddisk/bgh/programs/wage_mf_ft_smsa.dta, replace;
file /volumes/ddisk/bgh/programs/wage_mf_ft_smsa.dta saved

. *MERGE IN DATA ON COUNTS BASED ON HOURS WORKED;
. *THE COUNTS INCLUDE THE SELF-EMPLOYED;
. sort survey smsa edcode;

. merge survey smsa edcode using /volumes/ddisk/bgh/programs/count_smsa.dta;
variables survey smsa edcode do not uniquely identify observations in the master data

. tab _merge;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          3 |      8,536      100.00      100.00
------------+-----------------------------------
      Total |      8,536      100.00

.  drop _merge;

. sort survey smsa edcode;

. merge survey smsa edcode using /volumes/ddisk/bgh/programs/pop_smsa.dta;
variables survey smsa edcode do not uniquely identify observations in the master data

. tab _merge;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          3 |      8,536      100.00      100.00
------------+-----------------------------------
      Total |      8,536      100.00

.  drop _merge;

. save /volumes/ddisk/bgh/programs/wage_mf_ft_smsa.dta, replace;
file /volumes/ddisk/bgh/programs/wage_mf_ft_smsa.dta saved

. log close;
       log:  /volumes/ddisk/bgh/programs/wage_mf_ft_smsa.log
  log type:  text
 closed on:  13 Jul 2011, 08:43:11
---------------------------------------------------------------------------------------------
