#delimit; clear; set mem 1000m; use ebenstei_econ_berkeley_edu_001.dta; ***********; * Renaming ; ***********; rename ethncn race; rename provcn province; rename prefeccn prefecture; gen cdied=chborn-chsurv; *********************; * Years of education ; *********************; gen yrsed=.; replace yrsed=. if educchn==0 & year==1982; replace yrsed=0 if educchn==1 & year==1982; replace yrsed=3 if educchn==2 & year==1982; replace yrsed=6 if educchn==3 & year==1982; replace yrsed=9 if educchn==4 & year==1982; replace yrsed=12 if educchn==5 & year==1982; replace yrsed=16 if educchn==6 & year==1982; **************; * Birth month ; **************; gen month=0; ********************************; * Relationship / Marital Status ; ********************************; rename relate relold; gen relate=.; replace relate=1 if relold==1000 & year==1982; replace relate=2 if relold==2100 & year==1982; replace relate=6 if relold==3000 & year==1982; replace relate=8 if relold==4100 & year==1982; replace relate=3 if relold==4200 & year==1982; replace relate=5 if relold==4600 & year==1982; replace relate=10 if relold==4910 & year==1982; replace relate=12 if relold==5000 & year==1982; rename marst marstold; gen marst=.; replace marst=1 if marstold==100 & year==1982; replace marst=2 if marstold==210 & year==1982; replace marst=3 if marstold==330 & year==1982; replace marst=4 if marstold==400 & year==1982; ********************************; * Relationship / Marital Status ; ********************************; * The census was carried out july 1st, 1982; gen married=marst==2; gen working=empstat==1000; gen birthyear=1982-age; **********; * Weights ; **********; gen perwt=1000; ****************; replace age=. if age>500; drop if age==.; tostring serial,generate(sernum); capture drop serial; egen serial=concat(sernum year), punct("-"); gen mypref=prefecture; tostring mypref, replace; rename prefecture oldprefecture; rename mypref prefecture; *keep year /* Region */ province prefecture oldprefecture geotypcn /* Individual and family identifiers */ serial pernum perwt /* Family relationship variables */ momloc poploc relate relold /* Core demographic variables */ age month sex married working marst marstold chborn chsurv cdied /* Ethnicity */ race /* Education and income */ lit edattain educchn empstat yrsed regstat occisco occ indgen ind; compress; sort serial pernum; save ~/data/china/china1982/china1982, replace; sort serial pernum; keep in 1/10000; save ~/data/china/china1982/china1982_small, replace;