---------------------------------------------------------------------------------------------
       log:  /volumes/ddisk/bgh/programs/pop_smsa.log
  log type:  text
 opened on:  13 Jul 2011, 08:19:01

. *NOTE THIS AGGREGATES ACROSS EXPERIENCE GROUPS;
. *THIS PROGRAM CALCULATES COUNT OF ALL PERSONS IN THE SKILL CELL, THE VARIABLE THAT WILL BE 
> THE INSTRUMENT;
. *THIS FILE COUNTS INDIVIDUALS FOR THE PREFERRED SPECIFICATION;
. *18-64, NON GQ, CORRECT DEFINITION OF IMMIGRANTS, EDUCREC FOR EDUCATION;
. use /volumes/ddisk/ipums2/ipums80.dta, clear;

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

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

. #delimit ;
delimiter now ;
. *THESE ARE THE RESTRICTIONS FOR THE POPULATION COUNTS IN PREFERRED SPECIFICATION;
. drop if gq==0 | gq==3 | gq==4;
(207783 observations deleted)

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

. rename perwt weight;

. *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;
(4887109 missing values generated)

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

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

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

. drop if exper<1 | exper>40;
(909254 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 pimmig=imm*weight;

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

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

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

. generate smsa=int(metaread/10);

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

. summ smsa;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        smsa |   4034663    454.6144    247.9924          4        932

. keep pimmig pnative pimmigm pnativem edcode smsa expcode;

. 
end of do-file

. collapse (sum) pimmig pnative pimmigm pnativem, by(smsa edcode);

. generate survey=1980;

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

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

. #delimit ;
delimiter now ;
. *THESE ARE THE RESTRICTIONS FOR THE POPULATION COUNTS IN PREFERRED SPECIFICATION;
. drop if gq==0 | gq==3 | gq==4;
(184586 observations deleted)

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

. rename perwt weight;

. *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;
(6170602 missing values generated)

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

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

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

. drop if exper<1 | exper>40;
(904076 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 pimmig=imm*weight;

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

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

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

. generate smsa=int(metaread/10);

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

. summ smsa;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        smsa |   4308243     459.346     251.437          4        936

. keep pimmig pnative pimmigm pnativem edcode smsa expcode;

. 
end of do-file

. collapse (sum) pimmig pnative pimmigm pnativem, by(smsa edcode);

. generate survey=1990;

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

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

. #delimit ;
delimiter now ;
. *THESE ARE THE RESTRICTIONS FOR THE POPULATION COUNTS IN PREFERRED SPECIFICATION;
. drop if gq==0 | gq==3 | gq==4;
(273660 observations deleted)

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

. rename perwt weight;

. *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;
(7170691 missing values generated)

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

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

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

. drop if exper<1 | exper>40;
(847936 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 pimmig=imm*weight;

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

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

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

. generate smsa=int(metaread/10);

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

. summ smsa;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        smsa |   5340668     460.334    251.9966          4        936

. keep pimmig pnative pimmigm pnativem edcode smsa expcode;

. 
end of do-file

. collapse (sum) pimmig pnative pimmigm pnativem, by(smsa edcode);

. generate survey=2000;

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

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

. #delimit ;
delimiter now ;
. *THESE ARE THE RESTRICTIONS FOR THE POPULATION COUNTS IN PREFERRED SPECIFICATION;
. drop if gq==0 | gq==3 | gq==4;
(119588 observations deleted)

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

. rename perwt weight;

. *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;
(4760752 missing values generated)

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

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

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

. drop if exper<1 | exper>40;
(620806 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 pimmig=imm*weight;

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

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

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

. generate smsa=int(metaread/10);

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

. summ smsa;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        smsa |   3450578    458.0426    254.0376          4        936

. keep pimmig pnative pimmigm pnativem edcode smsa expcode;

. 
end of do-file

. collapse (sum) pimmig pnative pimmigm pnativem, by(smsa edcode);

. 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/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 smsa edcode;

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

. log close;
       log:  /volumes/ddisk/bgh/programs/pop_smsa.log
  log type:  text
 closed on:  13 Jul 2011, 08:21:41
---------------------------------------------------------------------------------------------
