clear _all set mem 150m set matsize 800 set more off capture log close set logtype text set trace off #delimit; global path C:; *log using $path/confucianism/logs/moms_taiwan.log, replace; /*================================================ Program: dataprep.do Author: Avi Ebenstein Created: October 2005 Purpose: Card Model =================================================*/ *============================================; * STEP 0: Gather data from KAP 2000 and 2003 ; *============================================; use $path/confucianism/datafiles/kapdata, clear; replace kstar=kstar0; gen cen1980=mbirthyear>=1940 & mbirthyear<=1959; gen cen1990=mbirthyear>=1950 & mbirthyear<=1969; gen cen2000=mbirthyear>=1960 & mbirthyear<=1979; keep if cen1980|cen1990|cen2000; rename kids realkids; gen agecat=1; gen mperwt=1; gen married=1; gen str country="kap"; /* everything above this needs to be redone */ ***********************************************; * Duplicate those who are between census years ; ***********************************************; gen idnum=_n; gen inboth1=cen1980 & cen1990; gen inboth2=cen1990 & cen2000; expand 2 if inboth1; bysort idnum: replace cen1980=1 if _n==1 & inboth1; bysort idnum: replace cen1980=0 if _n==2 & inboth1; bysort idnum: replace cen1990=0 if _n==1 & inboth1; bysort idnum: replace cen1990=1 if _n==2 & inboth1; expand 2 if inboth2; bysort idnum: replace cen1990=1 if _n==1 & inboth2; bysort idnum: replace cen1990=0 if _n==2 & inboth2; bysort idnum: replace cen2000=0 if _n==1 & inboth2; bysort idnum: replace cen2000=1 if _n==2 & inboth2; for num 1980(10)2000: replace year=X if cenX==1; *============================================; * STEP 1: Parameter initialization ; *============================================; **************; * No abortion ; **************; for num 1/5: gen srX=.51; *============================================; * STEP 2: Simulation of child sex outcomes ; *============================================; gen kids=0; gen bnum=0; gen gnum=0; forvalues i=1/5{; ****************************; * Those willing to try zero,; * 1, or 2 more than kstar ; ****************************; local h=`i'-1; local g=`i'-2; gen k`i'=0; replace k`i'=1 if type==1 & kstar>=`i'; replace k`i'=1 if (type==2 & kstar>=`i')| (type==2 & (kstar>=`h' & bnum==0)); replace k`i'=1 if (type==3 & kstar>=`i')| (type==3 & (kstar>=`g' & bnum==0)); gen sexrand`i'=uniform(); gen b`i'=sexrand`i'>sr`i' & k`i'; gen g`i'=sexrand`i'