---------------------------------------------------------------------------------------------
       log:  /volumes/ddisk/bgh/programs/pop_national.log
  log type:  text
 opened on:  13 Jul 2011, 09:02:50

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

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

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

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

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

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

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

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

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

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

. drop if exper<1 | exper>40;
(116500 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);

. keep pimmig pnative pimmigm pnativem edcode state expcode;

. collapse (sum) pimmig pnative pimmigm pnativem, 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 byte imm=(citizen==2 | citizen==3);

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

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

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

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

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

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

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

. drop if exper<1 | exper>40;
(159474 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);

. keep pimmig pnative pimmigm pnativem edcode state expcode;

. collapse (sum) pimmig pnative pimmigm pnativem, 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);

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

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

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

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

. keep pimmig pnative pimmigm pnativem edcode state expcode;

. collapse (sum) pimmig pnative pimmigm pnativem, 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);

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

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

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

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

. keep pimmig pnative pimmigm pnativem edcode state expcode;

. collapse (sum) pimmig pnative pimmigm pnativem, 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);

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

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

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

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

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

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

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

. drop if exper<1 | exper>40;
(860052 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);

. keep pimmig pnative pimmigm pnativem edcode state expcode;

. collapse (sum) pimmig pnative pimmigm pnativem, 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);

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

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

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

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

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

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

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

. drop if exper<1 | exper>40;
(205397 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);

. keep pimmig pnative pimmigm pnativem edcode state expcode;

. collapse (sum) pimmig pnative pimmigm pnativem, 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/pop_national.dta, replace;
(note: file /volumes/ddisk/bgh/programs/pop_national.dta not found)
file /volumes/ddisk/bgh/programs/pop_national.dta saved

. log close;
       log:  /volumes/ddisk/bgh/programs/pop_national.log
  log type:  text
 closed on:  13 Jul 2011, 09:04:23
---------------------------------------------------------------------------------------------
