---------------------------------------------------------------------------------------------
       log:  /volumes/ddisk/bgh/programs/count_national.log
  log type:  text
 opened on:  13 Jul 2011, 09:00:07

. *THIS GETS COUNT BY EDCODE AND STATE;
. *FIRST WE GET COUNTS OF HOURS THAT INCLUDE THE SELF-EMPLOYED;
. *THIS FILE COUNTS INDIVIDUALS BY HOURS WORKED FOR THE PREFERRED SPECIFICATION;
. *18-64, NON GQ, POSITIVE WEEKS WORKED, CORRECT DEFINITION OF IMMIGRANTS, EDUCREC FOR EDUCAT
> ION;
. 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) ;

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

. #delimit ;
delimiter now ;
. *THIS COUNT PROGRAM INCLUDES THE SELF-EMPLOYED;
. drop if gq==0 | gq==3 | gq==4;
(27413 observations deleted)

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

. generate nweight=perwt;

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

. rename perwt weight;

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

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

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

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

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

. drop if exper<1 | exper>40;
(75284 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 & exper<=35) 
>         + 8*(exper>=36 & exper<=40);

. gen immig=imm*weight;

. gen native=(1-imm)*weight;

. gen immigm=imm*weight*(sex==1);

. gen nativem=(1-imm)*weight*(sex==1);

. gen nimmig=imm*nweight;

. gen nnative=(1-imm)*nweight;

. gen nimmigm=imm*nweight*(sex==1);

. gen nnativem=(1-imm)*nweight*(sex==1);

. *NOTE THAT IT AGGREGATES ACROSS ALL EXPERIENCE GROUPS;
. keep state immig native immigm nativem nimmig nnative nimmigm nnativem edcode expcode;

. collapse (sum) immig native immigm nativem nimmig nnative nimmigm nnativem, by(edcode);

. 
end of do-file

. generate survey=1960;

. 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) ;

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

. #delimit ;
delimiter now ;
. *THIS COUNT PROGRAM INCLUDES THE SELF-EMPLOYED;
. drop if gq==0 | gq==3 | gq==4;
(33292 observations deleted)

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

. generate nweight=perwt;

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

. rename perwt weight;

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

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

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

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

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

. drop if exper<1 | exper>40;
(111368 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 & exper<=35) 
>         + 8*(exper>=36 & exper<=40);

. gen immig=imm*weight;

. gen native=(1-imm)*weight;

. gen immigm=imm*weight*(sex==1);

. gen nativem=(1-imm)*weight*(sex==1);

. gen nimmig=imm*nweight;

. gen nnative=(1-imm)*nweight;

. gen nimmigm=imm*nweight*(sex==1);

. gen nnativem=(1-imm)*nweight*(sex==1);

. *NOTE THAT IT AGGREGATES ACROSS ALL EXPERIENCE GROUPS;
. keep state immig native immigm nativem nimmig nnative nimmigm nnativem edcode expcode;

. collapse (sum) immig native immigm nativem nimmig nnative nimmigm nnativem, by(edcode);

. 
end of do-file

. generate survey=1970;

. 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 hours=uhrswork;

. generate weeks=wkswork1;

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

. #delimit ;
delimiter now ;
. *THIS COUNT PROGRAM INCLUDES THE SELF-EMPLOYED;
. drop if gq==0 | gq==3 | gq==4;
(148176 observations deleted)

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

. generate nweight=perwt;

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

. rename perwt weight;

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

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

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

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

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

. drop if exper<1 | exper>40;
(598985 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 & exper<=35) 
>         + 8*(exper>=36 & exper<=40);

. gen immig=imm*weight;

. gen native=(1-imm)*weight;

. gen immigm=imm*weight*(sex==1);

. gen nativem=(1-imm)*weight*(sex==1);

. gen nimmig=imm*nweight;

. gen nnative=(1-imm)*nweight;

. gen nimmigm=imm*nweight*(sex==1);

. gen nnativem=(1-imm)*nweight*(sex==1);

. *NOTE THAT IT AGGREGATES ACROSS ALL EXPERIENCE GROUPS;
. keep state immig native immigm nativem nimmig nnative nimmigm nnativem edcode expcode;

. collapse (sum) immig native immigm nativem nimmig nnative nimmigm nnativem, by(edcode);

. 
end of do-file

. generate survey=1980;

. 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 hours=uhrswork;

. generate weeks=wkswork1;

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

. #delimit ;
delimiter now ;
. *THIS COUNT PROGRAM INCLUDES THE SELF-EMPLOYED;
. drop if gq==0 | gq==3 | gq==4;
(133685 observations deleted)

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

. generate nweight=perwt;

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

. rename perwt weight;

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

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

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

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

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

. drop if exper<1 | exper>40;
(592488 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 & exper<=35) 
>         + 8*(exper>=36 & exper<=40);

. gen immig=imm*weight;

. gen native=(1-imm)*weight;

. gen immigm=imm*weight*(sex==1);

. gen nativem=(1-imm)*weight*(sex==1);

. gen nimmig=imm*nweight;

. gen nnative=(1-imm)*nweight;

. gen nimmigm=imm*nweight*(sex==1);

. gen nnativem=(1-imm)*nweight*(sex==1);

. *NOTE THAT IT AGGREGATES ACROSS ALL EXPERIENCE GROUPS;
. keep state immig native immigm nativem nimmig nnative nimmigm nnativem edcode expcode;

. collapse (sum) immig native immigm nativem nimmig nnative nimmigm nnativem, by(edcode);

. 
end of do-file

. generate survey=1990;

. 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)

. generate hours=uhrswork;

. generate weeks=wkswork1;

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

. #delimit ;
delimiter now ;
. *THIS COUNT PROGRAM INCLUDES THE SELF-EMPLOYED;
. drop if gq==0 | gq==3 | gq==4;
(175946 observations deleted)

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

. generate nweight=perwt;

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

. rename perwt weight;

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

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

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

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

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

. drop if exper<1 | exper>40;
(554655 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 & exper<=35) 
>         + 8*(exper>=36 & exper<=40);

. gen immig=imm*weight;

. gen native=(1-imm)*weight;

. gen immigm=imm*weight*(sex==1);

. gen nativem=(1-imm)*weight*(sex==1);

. gen nimmig=imm*nweight;

. gen nnative=(1-imm)*nweight;

. gen nimmigm=imm*nweight*(sex==1);

. gen nnativem=(1-imm)*nweight*(sex==1);

. *NOTE THAT IT AGGREGATES ACROSS ALL EXPERIENCE GROUPS;
. keep state immig native immigm nativem nimmig nnative nimmigm nnativem edcode expcode;

. collapse (sum) immig native immigm nativem nimmig nnative nimmigm nnativem, by(edcode);

. 
end of do-file

. generate survey=2000;

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

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

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

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

. generate hours=uhrswork;

. generate weeks=wkswork1;

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

. #delimit ;
delimiter now ;
. *THIS COUNT PROGRAM INCLUDES THE SELF-EMPLOYED;
. drop if gq==0 | gq==3 | gq==4;
(33781 observations deleted)

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

. generate nweight=perwt;

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

. rename perwt weight;

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

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

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

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

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

. drop if exper<1 | exper>40;
(134909 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 & exper<=35) 
>         + 8*(exper>=36 & exper<=40);

. gen immig=imm*weight;

. gen native=(1-imm)*weight;

. gen immigm=imm*weight*(sex==1);

. gen nativem=(1-imm)*weight*(sex==1);

. gen nimmig=imm*nweight;

. gen nnative=(1-imm)*nweight;

. gen nimmigm=imm*nweight*(sex==1);

. gen nnativem=(1-imm)*nweight*(sex==1);

. *NOTE THAT IT AGGREGATES ACROSS ALL EXPERIENCE GROUPS;
. keep state immig native immigm nativem nimmig nnative nimmigm nnativem edcode expcode;

. collapse (sum) immig native immigm nativem nimmig nnative nimmigm nnativem, by(edcode);

. 
end of do-file

. gen survey=2006;

. 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;

. sort survey edcode;

.  save /volumes/ddisk/bgh/programs/count_national.dta, replace;
(note: file /volumes/ddisk/bgh/programs/count_national.dta not found)
file /volumes/ddisk/bgh/programs/count_national.dta saved

. log close;
       log:  /volumes/ddisk/bgh/programs/count_national.log
  log type:  text
 closed on:  13 Jul 2011, 09:02:30
---------------------------------------------------------------------------------------------
