---------------------------------------------------------------------------------------------
       log:  /volumes/ddisk/bgh/programs/wage_mf_national.log
  log type:  text
 opened on:  13 Jul 2011, 09:11:23

. *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/bgh/data/ipums60.dta, clear;

. generate byte imm=(bpld>=15000);

.    replace imm=0 if bpld==90011 | bpld==90021;
(4000 real changes made)

. drop if wkswork2==0;
(1025610 observations deleted)

. generate hours=7.5*(hrswork2==1) + 22*(hrswork2==2) + 32*(hrswork2==3) + 37*(hrswork2==4) 
>         + 40*(hrswork2==5) + 44.5*(hrswork2==6) 
>         + 54*(hrswork2==7) + 70*(hrswork2==8) ;

. generate weeks=6.5*(wkswork2==1) + 20*(wkswork2==2) + 33*(wkswork2==3) + 43.5*(wkswork2==4)
>  
>         + 48.5*(wkswork2==5) + 51*(wkswork2==6) ;

. *generate pdeflator=4.75;
. *REPLACE WITH OP DEFLATOR;
. generate pdeflator=5.725;

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

. replace incwage=25000*1.5 if incwage==25000;
(1740 real changes made)

. replace incbusfm=25000*1.5 if incbusfm==25000;
(275 real changes made)

. gen incearn=incwage+incbusfm;

. *SELECT FULL-TIME WORKERS;
. *drop it weeks<40;
. *drop if hours<35;
. * DEFINE SAMPLE RESTRICTIONS, COMMON VARIABLES;
. do /volumes/ddisk/bgh/programs/restriction_wage_mf_national.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
(674993 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;
(25055 observations deleted)

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

. keep if classwkd>=20 & classwkd<=28;
(11620 observations deleted)

. rename perwt weight;

. rename perwt2 perwt;

. generate byte edcode=1*(educrec<=6) + 2*(educrec==7) + 3*(educrec==8) + 4*(educrec==9);

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

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

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

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

. drop if exper<1 | exper>40;
(62803 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);
(517248 real changes made)

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

. generate weekly=(incwage/weeks);

. generate annual=(incwage);

. generate wage=incwage/(weeks*hours);
(85119 missing values generated)

. generate lweekly=log(weekly);

. *NOTE THAT MEAN EARNINGS ARE WEIGHTED BY HOURS WORKED;
. collapse (mean) lweekly weekly (count) sizew=weight (rawsum) sumweight=weight
>         (sd) slweekly=lweekly sweekly=weekly [aw=weight], by(imm edcode);

. 
end of do-file

. generate survey=1960;

. sort survey edcode;

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

. use /volumes/ddisk/bgh/data/ipums70.dta, clear;

. generate school=higraded - (int(higraded/10))*10;

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

. drop if wkswork2==0;
(1097091 observations deleted)

. generate hours=7.5*(hrswork2==1) + 22*(hrswork2==2) + 32*(hrswork2==3)  + 37*(hrswork2==4) 
>         + 40*(hrswork2==5) + 44.5*(hrswork2==6) 
>         + 54*(hrswork2==7) + 70*(hrswork2==8) ;

. generate weeks=6.5*(wkswork2==1) + 20*(wkswork2==2) + 33*(wkswork2==3) + 43.5*(wkswork2==4)
>  
>         + 48.5*(wkswork2==5) + 51*(wkswork2==6) ;

. *generate pdeflator=3.63;
. *REPLACE WITH OP DEFLATOR;
. generate pdeflator=4.54;

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

. replace incwage=50000*1.5 if incwage==50000;
(1381 real changes made)

. replace incbus=50000*1.5 if incbus==50000;
(120 real changes made)

. replace incfarm=50000*1.5 if incfarm==50000;
(3 real changes made)

. gen incearn=incwage+incbus+incfarm;

. *SELECT FULL-TIME WORKERS;
. *drop it weeks<40;
. *drop if hours<35;
. * DEFINE SAMPLE RESTRICTIONS, COMMON VARIABLES;
. do /volumes/ddisk/bgh/programs/restriction_wage_mf_national.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
(868636 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;
(32341 observations deleted)

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

. keep if classwkd>=20 & classwkd<=28;
(20946 observations deleted)

. rename perwt weight;

. rename perwt2 perwt;

. generate byte edcode=1*(educrec<=6) + 2*(educrec==7) + 3*(educrec==8) + 4*(educrec==9);

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

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

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

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

. drop if exper<1 | exper>40;
(101307 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);
(633151 real changes made)

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

. generate weekly=(incwage/weeks);

. generate annual=(incwage);

. generate wage=incwage/(weeks*hours);
(106417 missing values generated)

. generate lweekly=log(weekly);

. *NOTE THAT MEAN EARNINGS ARE WEIGHTED BY HOURS WORKED;
. collapse (mean) lweekly weekly (count) sizew=weight (rawsum) sumweight=weight
>         (sd) slweekly=lweekly sweekly=weekly [aw=weight], by(imm edcode);

. 
end of do-file

. generate survey=1970;

. sort survey edcode;

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

. use /volumes/ddisk/bgh/data/ipums80.dta, clear;

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

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

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

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

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

. replace incbus=75000*1.5 if incbus==75000;
(1736 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 it weeks<40;
. *drop if hours<35;
. * DEFINE SAMPLE RESTRICTIONS, COMMON VARIABLES;
. do /volumes/ddisk/bgh/programs/restriction_wage_mf_national.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
(5015528 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;
(144891 observations deleted)

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

. keep if classwkd>=20 & classwkd<=28;
(156087 observations deleted)

. rename perwt weight;

. rename perwt2 perwt;

. generate byte edcode=1*(educrec<=6) + 2*(educrec==7) + 3*(educrec==8) + 4*(educrec==9);

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

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

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

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

. drop if exper<1 | exper>40;
(553783 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);
(4137820 real changes made)

. replace incwage=incwage*(pdeflator);
incwage was long now double
(4137890 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;
. collapse (mean) lweekly weekly (count) sizew=weight (rawsum) sumweight=weight
>         (sd) slweekly=lweekly sweekly=weekly [aw=weight], by(imm edcode);

. 
end of do-file

. generate survey=1980;

. sort survey edcode;

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

. use /volumes/ddisk/bgh/data/ipums90.dta, clear;

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

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

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

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

. generate weeks=wkswork1;

. generate hours=uhrswork;

. *SELECT FULL-TIME WORKERS;
. *drop it weeks<40;
. *drop if hours<35;
. * DEFINE SAMPLE RESTRICTIONS, COMMON VARIABLES;
. do /volumes/ddisk/bgh/programs/restriction_wage_mf_national.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
(5798137 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;
(130302 observations deleted)

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

. keep if classwkd>=20 & classwkd<=28;
(221978 observations deleted)

. rename perwt weight;

. rename perwt2 perwt;

. generate byte edcode=1*(educrec<=6) + 2*(educrec==7) + 3*(educrec==8) + 4*(educrec==9);

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

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

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

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

. drop if exper<1 | exper>40;
(542874 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
(4898724 real changes made)

. replace incwage=incwage*(pdeflator);
incwage was long now double
(4898848 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;
. collapse (mean) lweekly weekly (count) sizew=weight (rawsum) sumweight=weight
>         (sd) slweekly=lweekly sweekly=weekly [aw=weight], by(imm edcode);

. 
end of do-file

. generate survey=1990;

. sort survey edcode;

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

. use /volumes/ddisk/bgh/data/ipums00.dta, clear;

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

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

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

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

. generate weeks=wkswork1;

. generate hours=uhrswork;

. *SELECT FULL-TIME WORKERS;
. *drop it weeks<40;
. *drop if hours<35;
. * DEFINE SAMPLE RESTRICTIONS, COMMON VARIABLES;
. do /volumes/ddisk/bgh/programs/restriction_wage_mf_national.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
(6543650 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;
(171288 observations deleted)

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

. keep if classwkd>=20 & classwkd<=28;
(267431 observations deleted)

. rename perwt weight;

. rename perwt2 perwt;

. generate byte edcode=1*(educrec<=6) + 2*(educrec==7) + 3*(educrec==8) + 4*(educrec==9);

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

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

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

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

. drop if exper<1 | exper>40;
(510271 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;
. collapse (mean) lweekly weekly (count) sizew=weight (rawsum) sumweight=weight
>         (sd) slweekly=lweekly sweekly=weekly [aw=weight], by(imm edcode);

. 
end of do-file

. generate survey=2000;

. sort survey edcode;

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

. use /volumes/ddisk/bgh/data/acs06.dta, clear;

. generate survey=2000+year;

. keep if survey==2006;
(0 observations deleted)

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

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

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

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

. generate weeks=wkswork1;

. generate hours=uhrswork;

. *SELECT FULL-TIME WORKERS;
. *drop it weeks<40;
. *drop if hours<35;
. * DEFINE SAMPLE RESTRICTIONS, COMMON VARIABLES;
. do /volumes/ddisk/bgh/programs/restriction_wage_mf_national.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
(1452631 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;
(32483 observations deleted)

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

. keep if classwkd>=20 & classwkd<=28;
(67589 observations deleted)

. rename perwt weight;

. rename perwt2 perwt;

. generate byte edcode=1*(educrec<=6) + 2*(educrec==7) + 3*(educrec==8) + 4*(educrec==9);

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

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

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

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

. drop if exper<1 | exper>40;
(123091 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
(1157802 real changes made)

. replace incwage=incwage*(pdeflator);
incwage was long now double
(1157802 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;
. collapse (mean) lweekly weekly (count) sizew=weight (rawsum) sumweight=weight
>         (sd) slweekly=lweekly sweekly=weekly [aw=weight], by(imm edcode);

. 
end of do-file

. 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/rep60.dta, clear;

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

. append using /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_national.dta, replace;
file /volumes/ddisk/bgh/programs/wage_mf_national.dta saved

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

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

. tab _merge;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          3 |         48      100.00      100.00
------------+-----------------------------------
      Total |         48      100.00

.  drop _merge;

. sort survey edcode;

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

. tab _merge;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          3 |         48      100.00      100.00
------------+-----------------------------------
      Total |         48      100.00

.  drop _merge;

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

. log close;
       log:  /volumes/ddisk/bgh/programs/wage_mf_national.log
  log type:  text
 closed on:  13 Jul 2011, 09:14:27
---------------------------------------------------------------------------------------------
