#delimit; clear; set mem 5000m; use ebenstei_econ_berkeley_edu_012.dta; keep if year==1982; ***********; * Renaming ; ***********; rename ethncn race; rename provcn province; rename prefcn prefecture; gen cdied=chborn-chsurv; *********************; * Years of education ; *********************; gen yrsed=.; replace yrsed=0 if educcn==0 & year==1982; replace yrsed=3 if educcn==10 & year==1982; replace yrsed=6 if educcn==20 & year==1982; replace yrsed=9 if educcn==30 & year==1982; replace yrsed=12 if educcn==40 & year==1982; replace yrsed=16 if educcn==50 & year==1982; replace yrsed=. if educcn==99 & year==1982; **************; * Birth month ; **************; gen month=0; ********************************; * Relationship / Marital Status ; ********************************; rename related relold; capture drop relate; gen relate=.; replace relate=1 if relold==1000 & year==1982; replace relate=2 if relold==2000 & year==1982; replace relate=6 if relold==3400 & year==1982; replace relate=8 if relold==4100 & year==1982; replace relate=3 if relold==4200 & year==1982; replace relate=5 if relold==4500 & year==1982; replace relate=10 if relold==4910 & year==1982; replace relate=10 if relold==5000 & year==1982; * No recode necessary for marital status; rename marst marstold; gen marst=.; replace marst=1 if marstold==1 & year==1982; replace marst=2 if marstold==2 & year==1982; replace marst=3 if marstold==3 & year==1982; replace marst=4 if marstold==4 & 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 educcn 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;