***************************** *Preamble ***************************** set more off clear *Define the working directory cd "E:\Wave_1" /*Define the data source directory, where there should contain ALL CFPS 2010 FILE*/ global datadir "E:\Original Data\CFPS" *we are using the English version in this dofile /*if using the Chinese version: "$datadir\cfps2010adult_report_nat092014.dta" */ use "$datadir\ecfps2010adult_112014.dta" /*if using the Chinese version: "$datadir\cfps2010family_report_nat092014.dta"*/ merge m:1 fid using "$datadir\ecfps2010family_112014.dta", keepusing (fswt_nat faminc_net welfare fd1 fd102 fd104 fd106 fd112 fd2 fd3 house_debts) drop if _merge == 2 drop _merge save File_CN, replace ***************************** *Part0. IDs and weights ***************************** * General information about survey gen a_syear = cyear lab var a_syear "Year of survey" tab a_syear,mi gen a_smonth = cmonth lab var a_smonth "Month of survey" tab a_smonth,mi * ID information gen a_pid = pid lab var a_pid "Individual ID" format a_pid %12.0g codebook a_pid,t(200) gen a_fid = fid lab var a_fid "Family id" codebook a_fid, t(200) gen a_cid = cid lab var a_cid "Community id" codebook a_cid, t(200) gen a_pidp = pid lab var a_pidp "Cross wave person identifier" * Sample weight gen a_pweight = rswt_nat lab var a_pweight "Individual sample weight" codebook a_pweight * Family sample weight a_fweight *fswt_nat clonevar a_fweight = fswt_nat label var a_fweight "Family Sample Weight" insp a_fweight save File_CN, replace ***************************** *Part1. Basic Demographic ***************************** * Birth year *qa1y_best gen a_birthy = qa1y_best mvdecode a_birthy, mv(-9) lab var a_birthy "R's year of birth" insp a_birthy * Birth Month gen a_birthm = qa1m lab var a_birthm "R's Month of birth" label define missing_label -8 "Not Applicable" -2 "Refuse to Answer"-1 "Don't Know" lab val a_birthm missing_label tab a_birthm * Age in 2010 gen a_age=qa1age lab var a_age "R's Age" insp a_age * Gender gen a_gender = gender replace a_gender = 2 if gender == 0 lab var a_gender "R's Gender" lab define a_gender_l 2 "Female" 1 "Male" lab values a_gender a_gender_l tab a_gender, mi * Ethnicity codebook qa5code,t(60) gen a_ethnica = qa5code label define a_ethnica_l -8 "Not Applicable" -2 "Refused to Answer" -1 "Don't Know" /// 1 "Han" 2 "Mongol" 3 "Hui" 4 "Tibetan" 6 "Miao" 7 "Yi" 8 "Zhuang" 9 "Buyi" /// 10 "Korean" 11 "Manchu" 12 "Dong" 13 "Yao" 14 "Bai" 15 "Tujia" 16 "Hani" 18 "Dai" /// 19 "Li" 21 "Wa" 22 "She" 24 "Lahu" 26 "Dongxiang" 27 "Naxi" 30 "Du" 34 "Blang" /// 37 "Gelao" 38 "Xibe" 52 "Oroqin" label value a_ethnica a_ethnica_l label var a_ethnica "R's Ethnicity" ta a_ethnica, mi * Ethnicity, Han gen a_ethnicb = a_ethnica replace a_ethnicb = 2 if a_ethnica >= 2 label define a_ethnicb_l -8 "Not Applicable" -2 "Refused to Answer" -1 "Don't Know" /// 1 "Majority: Han" 2 "Minority" label value a_ethnicb a_ethnicb_l label var a_ethnicb "R's Ethnicity: Majority or not" tab a_ethnicb, mi * Residence, urban/rural area gen a_urban= urban replace a_urban = 2 if urban == 0 //rural label define a_urban_l 1"Urban" 2"Rural" label value a_urban a_urban_l label var a_urban "Place of residence is urban or rural" tab a_urban, mi * No. of siblings gen a_sib=qb1 label var a_sib "Number of siblings" label define numeric_l -8 "Not Applicable" -2 "Refuse to Answer"-1 "Don't Know" label values a_sib numeric_l tab a_sib, mi tab a_sib if a_sib >=0 * Birth order gen a_birthorder = 1 forvalues j = 1/15 { replace a_birthorder = a_birthorder + 1 if qb301_a_`j' == 1 | qb301_a_`j' == 2 } replace a_birthorder = 1 if qb1 == 0 replace a_birthorder = qb1 if qb1 < 0 //**missing values same as a_sib replace a_birthorder = . if qb301_a_1 <0 & qb301_a_2 <0 & qb301_a_3 <0 & qb301_a_4 <0 & qb301_a_5 <0 & qb301_a_6 <0 & qb301_a_7 <0 & qb301_a_8 <0 & qb301_a_9 <0 & qb301_a_10 <0 & qb301_a_11 <0 & qb301_a_12 <0 & qb301_a_13 <0 & qb301_a_14 <0 & qb301_a_15 <0 & a_sib >= 2 label variable a_birthorder "Birth order of R" label value a_birthorder numeric_l tab a_birthorder, mi tab a_birthorder if a_birthorder > 0 * Year of birth of R's father a_birthy_f *tb1y_a_f gen a_birthy_f = tb1y_a_f recode a_birthy_f (-9=.) label var a_birthy_f "Year of birth of R's father" label value a_birthy_f numeric_l tab a_birthy_f, mi sum a_birthy_f if a_birthy_f >0 * Age of R's father a_age_f *tb1b_a_f gen a_age_f = tb1b_a_f recode a_age_f (-9=.) replace a_age_f =-8 if alive_a_f == 0 //died label variable a_age_f "Age of R's father" label value a_age_f numeric_l tab a_age_f, mi sum a_age_f if a_age_f >0 * Year of birth of R's mother a_birthy_m *tb1y_a_m gen a_birthy_m = tb1y_a_m recode a_birthy_m (-9=.) label var a_birthy_m "Year of birth of R's Mother" label value a_birthy_m numeric_l tab a_birthy_m, mi sum a_birthy_m if a_birthy_m >0 * Age of R's mother a_age_m *tb1b_a_m gen a_age_m = tb1b_a_m recode a_age_m (-9=.) replace a_age_m =-8 if alive_a_m == 0 //died label variable a_age_m "Age of R's mother" label value a_age_m numeric_l tab a_age_m, mi sum a_age_m if a_age_m >0 * Year of birth of R's spouse a_birthy_s *tb1y_a_s gen a_birthy_s = tb1y_a_s recode a_birthy_s (-9=.) label value a_birthy_s numeric_l label var a_birthy_s "Year of birth of R's spouse" tab a_birthy_s, mi sum a_birthy_s if a_birthy_s > 0 * Age of R's spouse a_age_s *tb1b_a_s gen a_age_s = tb1b_a_s recode a_age_s (-9=.) replace a_age_s = -8 if alive_a_s == 0 label value a_age_s numeric_l label var a_age_s "Age of R's spouse" tab a_age_s, mi sum a_age_s if a_age_s > 0 * Number of children of R a_child gen a_child = 0 forvalues i = 1/10{ replace a_child = a_child + 1 if tb1y_a_c`i' != -8 & tb1y_a_c`i' != -8 } label value a_child numeric_l label var a_child "Number of Children of R" tab a_child, mi tab a_child if a_child >=0 * Year of birth of R's children a_birthy_c1-a_birthy_c10 * Month of birth of R's children a_birthm_c1-a_birthm_c10 * Age of R's children a_age_c1-a_age_c10 forvalues i = 1/10 { gen a_birthy_c`i' = tb1y_a_c`i' recode a_birthy_c`i' (-9=.) label value a_birthy_c`i' numeric_l label var a_birthy_c`i' "Year of Birth of R's Children" gen a_birthm_c`i' = tb1m_a_c`i' recode a_birthm_c`i' (-9=.) (16=.) label value a_birthm_c`i' numeric_l label var a_birthm_c`i' "Month of Birth of R's Children" gen a_age_c`i' = tb1b_a_c`i' recode a_age_c`i' (-9=.) replace a_age_c`i' = -8 if alive_a_c`i' == 0 //died label value a_age_c`i' numeric_l label var a_age_c`i' "Age of R's Children" } ***************************** *Part 2. Education ***************************** * Year of schooling gen a_eduy = eduy2010 label var a_eduy "Years of schooling of R" tab a_eduy,mi tab a_eduy if a_eduy >=0 * Years of schooling of R's spouse a_eduy_s *sedul gen a_eduy_s = sedul replace a_eduy_s = -8 if qe1_best !=2 & mi(a_eduy_s) label var a_eduy_s "Years of schooling of R's spouse" label value a_eduy_s numeric_l tab a_eduy_s,mi tab a_eduy_s if a_eduy_s >=0 * ISCED 2011 education level gen a_edu = . replace a_edu = 1 if (edu2010 <= 2 & edu2010 >= 1) // 1. Elementary and Below replace a_edu = 2 if edu2010 == 3 // 2. Junior High and Vocational School replace a_edu = 3 if edu2010 == 4 // 03. Senior High and Vocational School replace a_edu = 4 if edu2010 == 5 // 4. Vocational College or Some College replace a_edu = 5 if edu2010 >= 6 & edu2010 <=8 //5 "Bachelor Degree and Above" label define a_edu_l 1 "Elementary and Below" 2 "Junior High and Vocational School" 3 "Senior High and Vocational School" 4 "Vocational College or Some College" 5 "Bachelor Degree and Above" -1 "Don't Know" -2 "Refuse to Answer" -8 "Not Applicable" label values a_edu a_edu_l label variable a_edu "Highest Educational Level Attained" tab a_edu, mi tab a_edu if a_edu >=0 * Highest educational level attained by R's father a_edu_f *fedu gen a_edu_f = fedu recode a_edu_f (1 2 =1) (3 = 2) (4=3)(5=4)(6 7 8 =5) label value a_edu_f a_edu_l label var a_edu_f "Highest educational level attained by R's father" tab a_edu_f, mi tab a_edu_f if a_edu_f >=0 * Highest educational level attained by R's mother a_edu_m *medu gen a_edu_m = medu recode a_edu_m (1 2 =1) (3 = 2) (4=3)(5=4)(6 7 8 =5) label value a_edu_m a_edu_l label var a_edu_m "Highest educational level attained by R's mother" tab a_edu_m, mi tab a_edu_m if a_edu_m >=0 * Highest educational level attained by R's spouse a_edu_s *sedu gen a_edu_s = sedu recode a_edu_s (1 2 =1) (3 = 2) (4=3)(5=4)(6 7 8 =5) label value a_edu_s a_edu_l label var a_edu_s "Highest educational level attained by R's spouse" tab a_edu_s, mi tab a_edu_s if a_edu_s >=0 ***************************** *Part 3. Individual's Labor Market Outcomes ***************************** * Employment status (employed, self-employed, unemployed, not in labor market (retired, full-time student,looking after family) a_employ gen a_employ=. replace a_employ=1 if qg3==1 replace a_employ=2 if qg3==0&qj1==1 //unemployed replace a_employ=3 if (qg3==0&qj101>=1)|(qg3==0&qd3==1) //not in labour market replace a_employ = qg3 if mi(a_employ) & qg3<0 replace a_employ = qj101 if mi(a_employ) & qj101 < 0 label var a_employ "Employment Status" label define a_employ_l 1 "Employed" /// 2 "Unemployed" /// 3 "Not in Labour Market" /// -8 "Not Applicable" -2 "Refused" -1 "Don't Know" label values a_employ a_employ_l tab a_employ,mi tab a_employ if a_employ>= 0 * Working hours per week a_workhour_week gen a_workhour_week= -8 // default is -8, not applicable replace a_workhour_week = (qg402/(30/7))*qg403 /// if (qg403 > 0 & qg402 > 0 & (qg402 != 31 | qg403 != 24 )) replace a_workhour_week = -8 if a_workhour_week == 168 label define a_workhour_l -8 "Not Applicable" /// -2 "Refused" /// -1 "Don't Know" label values a_workhour_week a_workhour_l label variable a_workhour_week "Working Hours per Week" sum a_workhour_week if a_workhour_week>0 tab a_workhour_week *define isco value label label define a_isco -8 `"Not Applicable"', modify label define a_isco -2 `"Refused"', modify label define a_isco -1 `"Don't Know"', modify label define a_isco 10 `"Armed forces"', modify label define a_isco 110 `"Legislators & Senior officials"', modify label define a_isco 111 `"Legislators"', modify label define a_isco 112 `"Senior government officials"', modify label define a_isco 113 `"Traditional chiefs and heads of villages"', modify label define a_isco 114 `"Senior officials of special interest organizations"', modify label define a_isco 120 `"Corporate managers"', modify label define a_isco 121 `"Directors and chief executives"', modify label define a_isco 122 `"Production and operations department managers"', modify label define a_isco 123 `"Other departmental managers"', modify label define a_isco 124 `"Office Manager"', modify label define a_isco 125 `"Military Officers"', modify label define a_isco 130 `"General managers"', modify label define a_isco 131 `"General managers"', modify label define a_isco 210 `"Physical, mathematical and engineering science professionals"', modify label define a_isco 211 `"Physicists, chemists and related professionals"', modify label define a_isco 212 `"Mathematicians, statisticians and related professionals"', modify label define a_isco 213 `"Computing professionals"', modify label define a_isco 214 `"Architects, engineers and related professionals"', modify label define a_isco 220 `"Life science and health professionals"', modify label define a_isco 221 `"Life science professionals"', modify label define a_isco 222 `"Health professionals (except nursing)"', modify label define a_isco 223 `"Nursing and midwifery professionals"', modify label define a_isco 230 `"Teaching professionals"', modify label define a_isco 231 `"College, university and higher education teaching professionals"', modify label define a_isco 232 `"Secondary education teaching professionals"', modify label define a_isco 233 `"Primary and pre-primary education teaching professionals"', modify label define a_isco 234 `"Special education teaching professionals"', modify label define a_isco 235 `"Other teaching professionals"', modify label define a_isco 240 `"Other professionals"', modify label define a_isco 241 `"Business professionals"', modify label define a_isco 242 `"Legal professionals"', modify label define a_isco 243 `"Archivists, librarians and related information professionals"', modify label define a_isco 244 `"Social sciences and related professionals"', modify label define a_isco 245 `"Writers and creative or performing artists"', modify label define a_isco 246 `"Religious professionals"', modify label define a_isco 310 `"Physical and engineering science associate professionals"', modify label define a_isco 311 `"Physical and engineering science technicians"', modify label define a_isco 312 `"Computer associate professionals"', modify label define a_isco 313 `"Optical and electronic equipment operators"', modify label define a_isco 314 `"Ship and aircraft controllers and technicians"', modify label define a_isco 315 `"Safety and quality inspectors"', modify label define a_isco 320 `"Life science and health associate professionals"', modify label define a_isco 321 `"Life science technicians and related associate professionals"', modify label define a_isco 322 `"Modern health associate professionals (except nursing)"', modify label define a_isco 323 `"Nursing and midwifery associate professionals"', modify label define a_isco 324 `"Traditional medicine practitioners and faith-healers"', modify label define a_isco 330 `"Teaching associate professionals"', modify label define a_isco 331 `"Primary education teaching associate professionals"', modify label define a_isco 332 `"Pre-primary education teaching associate professionals"', modify label define a_isco 333 `"Special education teaching associate professionals"', modify label define a_isco 334 `"Other teaching associate professionals"', modify label define a_isco 340 `"Other associate professionals"', modify label define a_isco 341 `"Finance and sales associate professionals"', modify label define a_isco 342 `"Business services agents and trade brokers"', modify label define a_isco 343 `"Administrative associate professionals"', modify label define a_isco 344 `"Customs, tax and related government associate professionals"', modify label define a_isco 345 `"Police inspectors and detectives"', modify label define a_isco 346 `"Social work associate professionals"', modify label define a_isco 347 `"Artistic, entertainment and sports associate professionals"', modify label define a_isco 348 `"Religious associate professionals"', modify label define a_isco 400 `"Clerks"', modify label define a_isco 410 `"Office clerks"', modify label define a_isco 411 `"Secretaries and keyboard-operating clerks"', modify label define a_isco 412 `"Numerical clerks"', modify label define a_isco 413 `"Material-recording and transport clerks"', modify label define a_isco 414 `"Library, mail and related clerks"', modify label define a_isco 419 `"Other office clerks"', modify label define a_isco 420 `"Customer service clerks"', modify label define a_isco 421 `"Cashiers, tellers and related clerks"', modify label define a_isco 422 `"Client information clerks"', modify label define a_isco 500 `"Service workers & Shop & Market sales Workers"', modify label define a_isco 510 `"Personal and protective services workers"', modify label define a_isco 511 `"Travel attendants and related workers"', modify label define a_isco 512 `"Housekeeping and restaurant services workers"', modify label define a_isco 513 `"Personal care and related workers"', modify label define a_isco 514 `"Other personal service workers"', modify label define a_isco 515 `"Astrologers, fortune-tellers and related workers"', modify label define a_isco 516 `"Protective services workers"', modify label define a_isco 520 `"Models, salespersons and demonstrators"', modify label define a_isco 521 `"Fashion and other models"', modify label define a_isco 522 `"Shop salespersons and demonstrators"', modify label define a_isco 523 `"Stall and market salespersons"', modify label define a_isco 610 `"Market-oriented skilled agricultural and fishery workers"', modify label define a_isco 611 `"Market gardeners and crop growers"', modify label define a_isco 612 `"Market-oriented animal producers and related workers"', modify label define a_isco 613 `"Market-oriented crop and animal producers"', modify label define a_isco 614 `"Forestry and related workers"', modify label define a_isco 615 `"Fishery workers, hunters and trappers"', modify label define a_isco 620 `"Subsistence agricultural and fishery workers"', modify label define a_isco 621 `"Subsistence agricultural and fishery workers"', modify label define a_isco 700 `"Craft etc trade workers"', modify label define a_isco 710 `"Extraction and building trade workers"', modify label define a_isco 711 `"Miners, shot-firers, stonecutters and carvers"', modify label define a_isco 712 `"Building frame and related trades workers"', modify label define a_isco 713 `"Building finishers and related trades workers"', modify label define a_isco 714 `"Painters, building structure cleaners and related trade workers"', modify label define a_isco 720 `"Metal, machinery and related trades workers"', modify label define a_isco 721 `"Metal moulders, welders, sheet-metalworkers, structural-metal preparers and related trades workers"', modify label define a_isco 722 `"Blacksmiths, toolmakers and related trades workers"', modify label define a_isco 723 `"Machinery mechanics and fitters"', modify label define a_isco 724 `"Electrical and electronic equipment mechanics and fitters"', modify label define a_isco 730 `"Precision, handicraft, printing and related trades workers"', modify label define a_isco 731 `"Precision workers in metal and related materials"', modify label define a_isco 732 `"Potters, glass-makers and related trades workers"', modify label define a_isco 733 `"Handicraft workers in wood, textile, leather and related materials"', modify label define a_isco 734 `"Printing and related trades workers"', modify label define a_isco 740 `"Other craft and related trades workers"', modify label define a_isco 741 `"Food processing and related trades workers"', modify label define a_isco 742 `"Wood treaters, cabinet-makers and related trades workers"', modify label define a_isco 743 `"Textile, garment and related trades workers"', modify label define a_isco 744 `"Felt, leather and shoemaking trades workers"', modify label define a_isco 810 `"Stationary plant and related operators"', modify label define a_isco 811 `"Mining and mineral-processing plant operators"', modify label define a_isco 812 `"Metal-processing plant operators"', modify label define a_isco 813 `"Glass, ceramics and related plant operators"', modify label define a_isco 814 `"Wood processing and papermaking plant operators"', modify label define a_isco 815 `"Chemical processing plant operators"', modify label define a_isco 816 `"Power production and related plant operators"', modify label define a_isco 817 `"Automated assembly-line and industrial robot operators"', modify label define a_isco 820 `"Machine operators and assemblers"', modify label define a_isco 821 `"Metal and mineral products machine operators"', modify label define a_isco 822 `"Chemical products machine operators"', modify label define a_isco 823 `"Rubber and plastic products machine operators"', modify label define a_isco 824 `"Wood products machine operators"', modify label define a_isco 825 `"Printing, binding and paper products machine operators"', modify label define a_isco 826 `"Textile, fur and leather products machine operators"', modify label define a_isco 827 `"Food and related products machine operators"', modify label define a_isco 828 `"Assemblers"', modify label define a_isco 829 `"Other machine operators and assemblers"', modify label define a_isco 830 `"Drivers and mobile plant operators"', modify label define a_isco 831 `"Locomotive engine-drivers and related workers"', modify label define a_isco 832 `"Motor vehicle drivers"', modify label define a_isco 833 `"Agricultural and other mobile plant operators"', modify label define a_isco 834 `"Ships' deck crews and related workers"', modify label define a_isco 900 `"Elementary Occupations"', modify label define a_isco 910 `"Sales and services elementary occupations"', modify label define a_isco 911 `"Street vendors and related workers"', modify label define a_isco 912 `"Shoe cleaning and other street services' elementary occupations"', modify label define a_isco 913 `"Domestic and related helpers, cleaners and launderers"', modify label define a_isco 914 `"Building caretakers, window and related cleaners"', modify label define a_isco 915 `"Messengers, porters, doorkeepers and related workers"', modify label define a_isco 916 `"Garbage collectors and related labourers"', modify label define a_isco 920 `"Agricultural, fishery and related labourers"', modify label define a_isco 921 `"Agricultural, fishery and related labourers"', modify label define a_isco 930 `"Labourers in mining, construction, manufacturing and transport"', modify label define a_isco 931 `"Mining and construction labourers"', modify label define a_isco 932 `"Manufacturing labourers"', modify label define a_isco 933 `"Transport labourers and freight handlers"', modify * Occupation (ISCO88/08 standardization) a_isco clonevar a_isco = qg307isco label var a_isco "Current occupation (ISCO88/08 standardization)" replace a_isco = qg307code if mi(a_isco) & qg307code < 0 recode a_isco (-7=-1) (.=-1) *keep the fist 3 digit replace a_isco = int(a_isco/10) if a_isco > 0 label value a_isco a_isco * Occupation of R's first job a_isco_first *qg6 is this your first job *qg601_isco occupation of the first job clonevar a_isco_first = qg601_isco label var a_isco_first "Occupation of R's first job" save File_CN, replace * Occupation of R's spouse's main job a_isco_s merge 1:1 pid using "$datadir\ecfps2010famconf_112014", keepusing (tb5_isco_a_f tb5_isco_a_m tb5_isco_a_s) drop if _merge==2 drop _merge clonevar a_isco_s = tb5_isco_a_s *keep the fist 3 digit replace a_isco_s = int(a_isco_s/10) if a_isco_s > 0 label value a_isco_s a_isco recode a_isco (-7=-1) (.=-1) * Occupation (ISCO) of R's father when R was a child a_isco_f clonevar a_isco_f = tb5_isco_a_f label var a_isco_f "Occupation (ISCO) of R's father" *keep the fist 3 digit replace a_isco_f = int(a_isco_f/10) if a_isco_f > 0 label value a_isco_f a_isco recode a_isco (-7=-1) (.=-1) * Occupation (ISCO) of R's mother when R was a child a_isco_m clonevar a_isco_m = tb5_isco_a_m label var a_isco_m "Occupation (ISCO) of R's father" *keep the fist 3 digit replace a_isco_m = int(a_isco_m/10) if a_isco_m > 0 label value a_isco_m a_isco recode a_isco (-7=-1) (.=-1) *make frequency table by 100 label define isco1 -8 "Not Applicable" -2 "Refuse to Answer"-1 "Don't Know" /// 1"Legislators, Senior Officials And Managers" /// 2"Professionals" /// 3"Technicians And Associate Professionals" /// 4"Clerks" /// 5"Service Workers And Shop And Market Sales Workers" /// 6"Skilled Agricultural And Fishery Workers" /// 7"Craft And Related Trades Workers" /// 8"Plant And Machine Operators And Assemblers" /// 9"Elementary Occupations" /// 0"Armed Forces" clonevar a_isco1 = a_isco replace a_isco1 = int(a_isco1/100) if a_isco1 > 0 clonevar a_isco1_s = a_isco_s replace a_isco1_s = int(a_isco1_s/100) if a_isco1_s > 0 clonevar a_isco1_f = a_isco_f replace a_isco1_f = int(a_isco1_f/100) if a_isco1_f > 0 clonevar a_isco1_m = a_isco_m replace a_isco1_m = int(a_isco1_m/100) if a_isco1_m > 0 label values a_isco1 isco1 label values a_isco1_s isco1 label values a_isco1_f isco1 label values a_isco1_m isco1 * Average monthly wage recode qk101 (-8=-8 "not applicable"), gen(a_monthinc) label var a_monthinc "Average monthly wage(main job)" label value a_monthinc numeric_l sum a_monthinc if a_monthinc >0 * Hour wage clonevar a_hourwage = a_monthinc replace a_hourwage = a_monthinc/qg402/qg403 if a_monthinc > 0 & qg402 > 0 & qg403 > 0 replace a_hourwage = a_monthinc if a_monthinc < 0 label var a_hourwage "Hour Wage" label value a_hourwage numeric_l sum a_hourwage if a_hourwage > 0 * Yearly income (main job) a_yearinc1 gen a_yearinc1 = . forvalues i = 1/6 { clonevar qk10`i'_x = qk10`i' replace qk10`i'_x = 0 if qk10`i'_x <0 } replace a_yearinc1 = (qk101_x +qk102_x)*12 +qk103_x +qk104_x replace a_yearinc1 = -8 if a_employ !=1 & a_yearinc1 == 0 label value a_yearinc1 numeric_l label var a_yearinc1 "Yearly Income (Main Job)" tab a_yearinc1 sum a_yearinc1 if a_yearinc1 > 0 gen a_yearinc2 = . replace a_yearinc2 = qk105_x +qk106_x replace a_yearinc2 = -8 if (a_employ !=1|qg7 != 1) & a_yearinc2 == 0 label value a_yearinc2 numeric_l label var a_yearinc2 "Income from other job last year " tab a_yearinc2 sum a_yearinc2 if a_yearinc2 > 0 * Annual pension recode qk107 (-8=-8 "not applicable"), gen(a_pensioninc) label var a_pensioninc "Annual pension (for retired)" label value a_pensioninc numeric_l sum a_pensioninc if a_pensioninc >0 * Annual total income recode income (-8=-8 "not applicable"), gen(a_income) label var a_income "Annual total income" label value a_income numeric_l sum a_income if a_income >=0 * EGP of R's main job clonevar a_egp = qg307egp label var a_egp "EGP of R's main job" list a_isco if a_employ==3&a_egp==1 replace a_egp = -8 if a_egp == 1 & a_employ == 3 label copy qg307egp a_egp_l label define a_egp_l -8"Not Applicable", modify label value a_egp a_egp_l tab a_egp,mi tab a_egp if a_egp >=0 * Industry of R's main job label define industry_code -8 "not applicable" -2 "refuse to answer" /// -7 "difficult to classify" -1 "don't know" /// 1 "Agriculture, forestry, fishing and hunting" /// 2 "Mining" 3 "Manufacture" 4 "Production and supply of electricity, gas, and water" /// 5 "Construction" 6 "Transportation, storage, and postal service" /// 7 "Information transmission, computers, and software industry" /// 8 "Wholesale and retail" /// 9 "Hotel and catering" 10 "Finance" 11 "Real estate" /// 12 "Rental and commercial service" /// 13 "Scientific research, technology services and geological survey" /// 14 "Water resource, environment and public facility management" /// 15 "Residential and other service industry" 16 "Education" /// 17 "Health, social security, and social welfare" /// 18 "Culture, sports, and entertainment" /// 19 "Public administration and social organization" 21 "other industries" gen a_industry = qg308code label var a_industry "Industry of main job" label values a_industry industry_code tab a_industry,mi tab a_industry if a_industry >=0 * Type of organization label define organization_type -8 "not applicable" -2 "refuse to answer" /// -1 "don't know" /// 1 "Government/Party/People¡¯s organization/Military" /// 2 "State-owned/Collectively-owned public institution/Research institute" /// 3 "State-owned/State-controlled enterprise" /// 4 "Collectively-owned enterprise" /// 5 "Joint stock cooperative enterprise" /// 6 "Limited liability company/Company limited by shares" /// 7 "Private enterprise" /// 8 "Enterprise invested in by Hong Kong/Macao/Taiwan Capital" /// 9 "Company invested in by foreign capital" /// 10 "Rural family business" 11 "Individually owned business (getihu)" /// 12 "Private non-profit organization" /// 13 "Association /Guild/Foundation/Social organization" /// 14 "Residential community committee/Village committee/Autonomous organization" /// 77 "Other" 17 "Unable to identify" gen a_orgtype = qg305 label var a_orgtype "Ognization type" label values a_orgtype organization_type tab a_orgtype,mi * Tenure of current job a_tenure *qg311: since when did you start your current job gen a_tenure = qg311 if qg311 < 0 replace a_tenure = a_syear - qg311 if qg311 > 1000 label values a_tenure missing_label label var a_tenure "Tenure of current job" tab a_tenure,mi sum a_tenure if a_tenure >0 * Job satisfaction a_jobsat clonevar a_jobsat = qg506 label define a_jobsat_l -8 "Not Applicable" -2 "Refused" /// -1 "Don't Know" 1 "Very Unsatisfied" 2 "Unsatisfied" /// 3 "Fair" 4 "Satisfied" 5 "Very Satisfied" label values a_jobsat a_jobsat_l label variable a_jobsat "Job Satisfaction" tab a_jobsat,mi tab a_jobsat if a_jobsat >=0 * Labor union member or not a_union *qa7_s_1 - qa7_s_14: Did you join any of the following associations? gen a_union = 0 local N = _N forvalues i = 1/`N' { forvalues j = 1/14 { if qa7_s_`j'[`i'] == 5 { qui replace a_union = 1 in `i' } if qa7_s_`j'[`i'] == -2 { qui replace a_union = -2 in `i' } if qa7_s_`j'[`i'] == -1 { qui replace a_union = -1 in `i' } } } label var a_union "Labor union member" label define a_union_code -8 "not applicable" -2 "refuse to answer" /// -1 "don't know" 0 "No" 1 "Yes" label values a_union a_union_code tab a_union,mi tab a_union if a_union >=0 * Whether has injury insurance a_injureinsur * Whether has unemployment insurance a_unemployinsur * Whether has pension a_pension * Whether has maternity insurance or whether it's included by R's health insurance a_materinsur /*injury insurance, unemployment insurance, pension, maternity insurance or whether it's included by R's health insurance medical insurance*/ gen a_pension = 0 gen a_materinsur = 0 gen a_unemployinsur = 0 gen a_injuryinsur = 0 gen a_healthinsur = 0 gen a_healthin = 0 local N = _N forvalues i = 1/`N' { forvalues j = 1/18 { if qj3_s_`j'[`i'] >= 1 & qj3_s_`j'[`i'] <= 5 { qui replace a_healthin = 1 in `i' } if qj3_s_`j'[`i'] == 6 |qj3_s_`j'[`i'] == 7| qj3_s_`j'[`i'] == 8{ qui replace a_pension = 1 in `i' } if qj3_s_`j'[`i'] == 9 { qui replace a_materinsur = 1 in `i' } if qj3_s_`j'[`i'] == 10 { qui replace a_unemployinsur = 1 in `i' } if qj3_s_`j'[`i'] == 11 { qui replace a_injuryinsur = 1 in `i' } } } label var a_healthinsur "whether has health insurance" label var a_pension "Whether has pension" label var a_materinsur "Whether has maternity insurance or whether it's included by R's health insurance" label var a_unemployinsur "Whether has unemployment insurance" label var a_injuryinsur "Whether has injury insurance" replace a_healthinsur=-8 if qj3_s_1==-8 replace a_healthinsur=-2 if qj3_s_1==-2 replace a_healthinsur=-1 if qj3_s_1==-1 replace a_pension=-8 if qj3_s_1==-8 replace a_pension=-2 if qj3_s_1==-2 replace a_pension=-1 if qj3_s_1==-1 replace a_materinsur=-8 if qj3_s_1==-8 replace a_materinsur=-2 if qj3_s_1==-2 replace a_materinsur=-1 if qj3_s_1==-1 replace a_unemployinsur=-8 if qj3_s_1==-8 replace a_unemployinsur=-2 if qj3_s_1==-2 replace a_unemployinsur=-1 if qj3_s_1==-1 replace a_injuryinsur=-8 if qj3_s_1==-8 replace a_injuryinsur=-2 if qj3_s_1==-2 replace a_injuryinsur=-1 if qj3_s_1==-1 label define insurance -8 "not applicable" -2 "refuse to answer" /// -1 "don't know" 0 "No" 1 "Yes" label values a_healthinsur insurance label values a_pension insurance label values a_materinsur insurance label values a_unemployinsur insurance label values a_injuryinsur insurance tab a_healthinsur tab a_pension tab a_materinsur tab a_unemployinsur tab a_injuryinsur save File_CN, replace ***************************** *Part. 4 Household Economic Activities ***************************** ******************************************************************************** *a_fstruc *a_fsize *a_gen *a_hhstruc ******************************************************************************** capture mkdir cncompute use "$datadir\ecfps2010adult_112014", clear gen age=2010-qa1y_best if qa1y_best>0 gen marry=qe1_best replace marry=. if marry<0 keep pid fid cid provcd countyid indno urban age marry edu qg307isei qg307siops save cncompute\basic, replace use "$datadir\ecfps2010child_112014", clear gen age=2010-wa1y if wa1y>0 gen marry=1 keep pid fid cid provcd countyid indno urban age marry edu append using cncompute\basic save cncompute\basic, replace use "$datadir\ecfps2010family_112014", clear by cid,sort:gen n=_n keep if n==1 keep cid urban //keep the first family in every community save cncompute\urban, replace use "$datadir\ecfps2010famconf_112014", clear keep pid fid code_a_* //keep all the family members save cncompute\china_fstruc, replace *compute family size by fid,sort:gen n=_n by fid,sort:gen size=_N *compute number of generations qui reshape wide pid code_a_* size, i(fid) j(n) qui for var code_a_* : replace X=-8 if X==. qui forvalues i=1/26 { gen gen`i'=1 //gen = 1 by default forvalues j=1/26 { //gen = 2 if there are father & mother replace gen`i'=2 if (code_a_f`i'==code_a_p`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_p`j' & code_a_m`i'>0) replace gen`i'=2 if (code_a_f`i'==code_a_s`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_s`j' & code_a_m`i'>0) } } qui forvalues i=1/26 { forvalues j=1/26 { //gen = 2 if there are children replace gen`i'=2 if (code_a_p`i'==code_a_c1`j' & code_a_p`i'>0) replace gen`i'=2 if (code_a_p`i'==code_a_c2`j' & code_a_p`i'>0) replace gen`i'=2 if (code_a_p`i'==code_a_c3`j' & code_a_p`i'>0) replace gen`i'=2 if (code_a_p`i'==code_a_c4`j' & code_a_p`i'>0) replace gen`i'=2 if (code_a_p`i'==code_a_c5`j' & code_a_p`i'>0) replace gen`i'=2 if (code_a_p`i'==code_a_c6`j' & code_a_p`i'>0) replace gen`i'=2 if (code_a_p`i'==code_a_c7`j' & code_a_p`i'>0) replace gen`i'=2 if (code_a_p`i'==code_a_c8`j' & code_a_p`i'>0) replace gen`i'=2 if (code_a_p`i'==code_a_c9`j' & code_a_p`i'>0) replace gen`i'=2 if (code_a_p`i'==code_a_c10`j' & code_a_p`i'>0) } } qui forvalues i=1/26 { forvalues j=1/26 { replace gen`i'=gen`j' if ((code_a_s`i'==code_a_p`j' & code_a_s`i'>0)) & gen`i'0) | (code_a_m`i'==code_a_m`j' & code_a_m`i'>0)) & gen`i'0) | (code_a_m`i'==code_a_c1`j' & code_a_m`i'>0)) replace gen`i'=3 if ((code_a_f`i'==code_a_c2`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c2`j' & code_a_m`i'>0)) replace gen`i'=3 if ((code_a_f`i'==code_a_c3`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c3`j' & code_a_m`i'>0)) replace gen`i'=3 if ((code_a_f`i'==code_a_c4`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c4`j' & code_a_m`i'>0)) replace gen`i'=3 if ((code_a_f`i'==code_a_c5`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c5`j' & code_a_m`i'>0)) replace gen`i'=3 if ((code_a_f`i'==code_a_c6`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c6`j' & code_a_m`i'>0)) replace gen`i'=3 if ((code_a_f`i'==code_a_c7`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c7`j' & code_a_m`i'>0)) replace gen`i'=3 if ((code_a_f`i'==code_a_c8`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c8`j' & code_a_m`i'>0)) replace gen`i'=3 if ((code_a_f`i'==code_a_c9`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c9`j' & code_a_m`i'>0)) replace gen`i'=3 if ((code_a_f`i'==code_a_c10`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c10`j' & code_a_m`i'>0)) } } qui forvalues i=1/26 { forvalues j=1/26 { replace gen`i'=3 if ((code_a_f`i'==code_a_p`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_p`j' & code_a_m`i'>0)) & gen`j'==2 replace gen`i'=3 if ((code_a_f`i'==code_a_s`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_s`j' & code_a_m`i'>0)) & gen`j'==2 } } qui forvalues i=1/26 { forvalues j=1/26 { replace gen`i'=3 if (code_a_p`i'==code_a_c1`j' & code_a_p`i'>0) & gen`j'==2 replace gen`i'=3 if (code_a_p`i'==code_a_c2`j' & code_a_p`i'>0) & gen`j'==2 replace gen`i'=3 if (code_a_p`i'==code_a_c3`j' & code_a_p`i'>0) & gen`j'==2 replace gen`i'=3 if (code_a_p`i'==code_a_c4`j' & code_a_p`i'>0) & gen`j'==2 replace gen`i'=3 if (code_a_p`i'==code_a_c5`j' & code_a_p`i'>0) & gen`j'==2 replace gen`i'=3 if (code_a_p`i'==code_a_c6`j' & code_a_p`i'>0) & gen`j'==2 replace gen`i'=3 if (code_a_p`i'==code_a_c7`j' & code_a_p`i'>0) & gen`j'==2 replace gen`i'=3 if (code_a_p`i'==code_a_c8`j' & code_a_p`i'>0) & gen`j'==2 replace gen`i'=3 if (code_a_p`i'==code_a_c9`j' & code_a_p`i'>0) & gen`j'==2 replace gen`i'=3 if (code_a_p`i'==code_a_c10`j' & code_a_p`i'>0) & gen`j'==2 } } qui forvalues i=1/26 { forvalues j=1/26 { replace gen`i'=gen`j' if ((code_a_s`i'==code_a_p`j' & code_a_s`i'>0)) & gen`i'0) | (code_a_m`i'==code_a_m`j' & code_a_m`i'>0)) & gen`i'0) | (code_a_m`i'==code_a_p`j' & code_a_m`i'>0)) & gen`j'==3 replace gen`i'=4 if ((code_a_f`i'==code_a_s`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_s`j' & code_a_m`i'>0)) & gen`j'==3 } } qui forvalues i=1/26 { forvalues j=1/26 { replace gen`i'=4 if (code_a_p`i'==code_a_c1`j' & code_a_p`i'>0) & gen`j'==3 replace gen`i'=4 if (code_a_p`i'==code_a_c2`j' & code_a_p`i'>0) & gen`j'==3 replace gen`i'=4 if (code_a_p`i'==code_a_c3`j' & code_a_p`i'>0) & gen`j'==3 replace gen`i'=4 if (code_a_p`i'==code_a_c4`j' & code_a_p`i'>0) & gen`j'==3 replace gen`i'=4 if (code_a_p`i'==code_a_c5`j' & code_a_p`i'>0) & gen`j'==3 replace gen`i'=4 if (code_a_p`i'==code_a_c6`j' & code_a_p`i'>0) & gen`j'==3 replace gen`i'=4 if (code_a_p`i'==code_a_c7`j' & code_a_p`i'>0) & gen`j'==3 replace gen`i'=4 if (code_a_p`i'==code_a_c8`j' & code_a_p`i'>0) & gen`j'==3 replace gen`i'=4 if (code_a_p`i'==code_a_c9`j' & code_a_p`i'>0) & gen`j'==3 replace gen`i'=4 if (code_a_p`i'==code_a_c10`j' & code_a_p`i'>0) & gen`j'==3 } } qui forvalues i=1/26 { forvalues j=1/26 { replace gen`i'=4 if ((code_a_f`i'==code_a_c1`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c1`j' & code_a_m`i'>0)) & gen`j'==2 replace gen`i'=4 if ((code_a_f`i'==code_a_c2`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c2`j' & code_a_m`i'>0)) & gen`j'==2 replace gen`i'=4 if ((code_a_f`i'==code_a_c3`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c3`j' & code_a_m`i'>0)) & gen`j'==2 replace gen`i'=4 if ((code_a_f`i'==code_a_c4`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c4`j' & code_a_m`i'>0)) & gen`j'==2 replace gen`i'=4 if ((code_a_f`i'==code_a_c5`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c5`j' & code_a_m`i'>0)) & gen`j'==2 replace gen`i'=4 if ((code_a_f`i'==code_a_c6`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c6`j' & code_a_m`i'>0)) & gen`j'==2 replace gen`i'=4 if ((code_a_f`i'==code_a_c7`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c7`j' & code_a_m`i'>0)) & gen`j'==2 replace gen`i'=4 if ((code_a_f`i'==code_a_c8`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c8`j' & code_a_m`i'>0)) & gen`j'==2 replace gen`i'=4 if ((code_a_f`i'==code_a_c9`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c9`j' & code_a_m`i'>0)) & gen`j'==2 replace gen`i'=4 if ((code_a_f`i'==code_a_c10`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c10`j' & code_a_m`i'>0)) & gen`j'==2 } } qui forvalues i=1/26 { forvalues j=1/26 { replace gen`i'=gen`j' if ((code_a_s`i'==code_a_p`j' & code_a_s`i'>0)) & gen`i'0) | (code_a_m`i'==code_a_m`j' & code_a_m`i'>0)) & gen`i'0) | (code_a_m`i'==code_a_p`j' & code_a_m`i'>0)) & gen`j'==4 replace gen`i'=5 if ((code_a_f`i'==code_a_s`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_s`j' & code_a_m`i'>0)) & gen`j'==4 } } qui forvalues i=1/26 { forvalues j=1/26 { replace gen`i'=5 if (code_a_p`i'==code_a_c1`j' & code_a_p`i'>0) & gen`j'==4 replace gen`i'=5 if (code_a_p`i'==code_a_c2`j' & code_a_p`i'>0) & gen`j'==4 replace gen`i'=5 if (code_a_p`i'==code_a_c3`j' & code_a_p`i'>0) & gen`j'==4 replace gen`i'=5 if (code_a_p`i'==code_a_c4`j' & code_a_p`i'>0) & gen`j'==4 replace gen`i'=5 if (code_a_p`i'==code_a_c5`j' & code_a_p`i'>0) & gen`j'==4 replace gen`i'=5 if (code_a_p`i'==code_a_c6`j' & code_a_p`i'>0) & gen`j'==4 replace gen`i'=5 if (code_a_p`i'==code_a_c7`j' & code_a_p`i'>0) & gen`j'==4 replace gen`i'=5 if (code_a_p`i'==code_a_c8`j' & code_a_p`i'>0) & gen`j'==4 replace gen`i'=5 if (code_a_p`i'==code_a_c9`j' & code_a_p`i'>0) & gen`j'==4 replace gen`i'=5 if (code_a_p`i'==code_a_c10`j' & code_a_p`i'>0) & gen`j'==4 } } qui forvalues i=1/26 { forvalues j=1/26 { replace gen`i'=5 if ((code_a_f`i'==code_a_c1`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c1`j' & code_a_m`i'>0)) & gen`j'==3 replace gen`i'=5 if ((code_a_f`i'==code_a_c2`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c2`j' & code_a_m`i'>0)) & gen`j'==3 replace gen`i'=5 if ((code_a_f`i'==code_a_c3`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c3`j' & code_a_m`i'>0)) & gen`j'==3 replace gen`i'=5 if ((code_a_f`i'==code_a_c4`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c4`j' & code_a_m`i'>0)) & gen`j'==3 replace gen`i'=5 if ((code_a_f`i'==code_a_c5`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c5`j' & code_a_m`i'>0)) & gen`j'==3 replace gen`i'=5 if ((code_a_f`i'==code_a_c6`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c6`j' & code_a_m`i'>0)) & gen`j'==3 replace gen`i'=5 if ((code_a_f`i'==code_a_c7`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c7`j' & code_a_m`i'>0)) & gen`j'==3 replace gen`i'=5 if ((code_a_f`i'==code_a_c8`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c8`j' & code_a_m`i'>0)) & gen`j'==3 replace gen`i'=5 if ((code_a_f`i'==code_a_c9`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c9`j' & code_a_m`i'>0)) & gen`j'==3 replace gen`i'=5 if ((code_a_f`i'==code_a_c10`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_c10`j' & code_a_m`i'>0)) & gen`j'==3 } } qui forvalues i=1/26 { forvalues j=1/26 { replace gen`i'=gen`j' if ((code_a_s`i'==code_a_p`j' & code_a_s`i'>0)) & gen`i'0) | (code_a_m`i'==code_a_m`j' & code_a_m`i'>0)) & gen`i'0) | (code_a_m`i'==code_a_p`j' & code_a_m`i'>0)) & (gen`i'-gen`j'!=1) replace gen`j'=gen`i'-1 if ((code_a_f`i'==code_a_s`j' & code_a_f`i'>0) | (code_a_m`i'==code_a_s`j' & code_a_m`i'>0)) & (gen`i'-gen`j'!=1) } } qui reshape long pid code_a_p code_a_f code_a_m code_a_s code_a_c1 code_a_c2 code_a_c3 code_a_c4 code_a_c5 code_a_c6 code_a_c7 code_a_c8 code_a_c9 code_a_c10 size gen, i(fid) j(n) drop if size==. by fid,sort : egen generation=max(gen) keep pid fid size gen generation save cncompute\generation1, replace * Family structure use "$datadir\ecfps2010famconf_112014", clear merge 1:1 pid using cncompute\generation1.dta keep if _merge==3 drop _merge merge 1:1 pid using cncompute\basic.dta drop if _merge==2 drop _merge *Whether married gen marr=tb3_a_p replace marr=marry if marr<0 | marr==. gen married=0 replace married=1 if marr>1 & marr<. & marr!=3 gen married_s=0 replace married_s=1 if (marr==2|marr==3)&marr<. *identify members belong to different generations in a family tostring fid,gen(fid1) gen fid2=fid1+"1" if gen==1 replace fid2=fid1+"2" if gen==2 replace fid2=fid1+"3" if gen==3 replace fid2=fid1+"4" if gen==4 replace fid2=fid1+"5" if gen==5 *count how many couples in a family gen tz=0 replace tz=1 if tb6_a_s==1 by fid2,sort:egen count1=total(tz) replace count1=count1/2 *count the largest number of couple pairs by fid,sort: egen count2=max(count1) *type=1 if there is only one person in the family gen type=1 if size==1 *type=2 if there is only one couple in the family replace type=2 if generation==1 & count2==1 & size==2 *type=5 joint family if there are two or more couples in one generation in the family replace type=5 if generation==1 & count2>1 *type=79 other family with only 1 generation in it replace type=79 if generation==1 & type==. *type=5 joint family if there are two or more couples in one generation replace type=5 if type==. & count2>1 *type=4 stem family if there are more than 2 generations in the family only 1 couple in each generation replace type=4 if generation>2 & type==. *whether son or daughter in the second generation is married in families with two generations gen jiehun=0 if generation==2 replace jiehun=1 if generation==2 & gen==2 & married==1 by fid,sort: egen jiehun1=max(jiehun) if generation==2 *type=3 couple with unmarried children replace type=3 if generation==2 & jiehun1==0 & type==. *whether father/mother not married, divorced or widowed gen jiehun2=0 if type==3 replace jiehun2=1 if generation==2 & gen==1 & married_s==1 by fid,sort: egen jiehun_gen1=max(jiehun2) if generation==2 *type=4 stem family with 2 genetation, son or daughter get married replace type=4 if generation==2 & jiehun1==1 & type==. gen type_crude=type *type=6 couple have children but not live together with them replace type=6 if type==2 & (code_a_c1>0 | code_a_c2>0 | code_a_c3>0 | code_a_c4>0 | code_a_c5>0 | code_a_c6>0 | code_a_c7>0 | code_a_c8>0 | code_a_c9>0 | code_a_c10>0) by fid,sort: egen type1=max(type) replace type=6 if type1!=type *type=7 family with generation 1 and generation 3 (grandparent with grandchildren) tab gen,gen(gen) by fid,sort: egen gen1_1=max(gen1) by fid,sort: egen gen2_1=max(gen2) by fid,sort: egen gen3_1=max(gen3) by fid,sort: egen gen4_1=max(gen4) by fid,sort: egen gen5_1=max(gen5) gen gen_1=gen1_1+gen2_1+gen3_1+gen4_1+gen5_1 replace type=7 if generation>gen_1 keep pid fid subpopulation subsample size marry gen generation type type_crude jiehun_gen1 label var size "family size" label var generation "number of generations in family" replace generation=4 if generation==5 label define generation -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" 1 "1 Generation" 2 "2 Generations" 3 "3 Generations" 4 "4 or more Generations" label val generation generation label var type "family structure" recode type 3=4 4=5 5=7 6=3 7=6 label define type 1 "primary individual family" 2 "couple with no child" 3 "couple have child but not live in this family" /// 4 "couple with children" 5 "stem family" 6 "stem family (grandparent+grandchild)" 7 "extended family" 79 "other family" label val type type label var type_crude "family structure_crude" label define type_crude 1 "primary individual family" 2 "couple with no child" 3 "couple with children" /// 4 "stem family" 5 "extended family" 79 "other family" label val type_crude type_crude *family strcuture for harmonization gen family_structure_temp = type_crude gen family_structure = family_structure_temp replace family_structure = 5 if family_structure_temp > 5 replace family_structure = 6 if family_structure_temp == 3 & jiehun_gen1==0 recode family_structure 2=3 3=4 4=5 5=6 6=2 tab type_crude tab family_structure label var family_structure "family structure with single parent family identified" label define family_structure 1 "primary individual family" 2 "single parent family" 3 "couple with no child" /// 4 "couple with children" 5 "stem family" 6 "extended and other family" label val family_structure family_structure recode family_structure (1=1) (2=2) (3=3) (4=4) (5/6=5), gen (family_structure2) label var family_structure2 "family structure harmonized" label define family_structure2 1 "primary individual family" 2 "single parent family" 3 "couple with no child" /// 4 "couple with children" 5 "other family" label val family_structure2 family_structure2 drop marry family_structure_temp jiehun_gen1 rename size a_fsize rename family_structure a_fstruc save cncompute\family_structure_C_final,replace use File_CN, clear merge 1:1 pid using cncompute\family_structure_C_final drop if _merge == 2 drop _merge /*English Label*/ label var a_fsize "Family Size" label define fstruc_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" /// 1 "Primary Individual Family" 2 "Single-Parent Family" 3 "Married Couple with No Children" /// 4 "Married Couple with Children" 5 "Stem" 6"Other Family" label value a_fstruc fstruc_l label var a_fstruc "Family Structure" tab a_fstruc tab a_fstruc if a_fstruc >=0 * Household structure: CFPS only focus on family units, thus household structure is the same with family structure clonevar a_hhstruc = a_fstruc //no non-relative in the hh gen a_gen = generation label var a_gen "Number of Generations in Family Unit" label define a_gen -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" 1 "1 Generation" 2 "2 Generations" 3 "3 Generations" 4 "4 or more Generations" label value a_gen a_gen save File_CN, replace * Pre-government Yearly Household Income a_faminc_pre gen a_faminc_pre = faminc_net-welfare label var a_faminc_pre "Pre-government Yearly Household Income" sum a_faminc_pre * Post-government Yearly Household Income a_faminc_post gen a_faminc_post=faminc_net label var a_faminc_post "Post-government Yearly Household Income" sum a_faminc_post insp a_faminc_post ***************************** *Part. 5 Marriage ***************************** * Current marriage *qe10_best current marriage status *qe310 married before the cohabitation? *qe401 why did you separate with the ex-partner? gen a_marriage = qe1_best recode a_marriage (-9 = .) (1 =2) (2=1) (5 = 3) replace a_marriage=4 if a_marriage==3&qe401==3 //divorced replace a_marriage=3 if a_marriage==3&qe401==5 //widowed replace a_marriage=-8 if a_marriage==3&qe310==1&qe401==-1 replace a_marriage=-8 if a_marriage==3&qe310==1&qe401==-8 label define mar_l -8 "Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 1 "Married" 2"Single" 3"Widowed" 4 "Divorced, annulment" label value a_marriage mar_l label var a_marriage "Current Marital Status" tab a_marriage, mi * Year of current marriage a_cmarri_y gen a_cmarri_y = qe210y label values a_cmarri_y missing_label label var a_cmarri_y "Year of current marriage" sum a_cmarri_y if a_cmarri_y>0 * Month of current marriage a_cmarri_m gen a_cmarri_m = qe210m label values a_cmarri_m missing_label label var a_cmarri_m "Month of current marriage" tab a_cmarri_m * Whether cohabited before current marriage a_cmarri_cohab //qe212 gen a_cmarri_cohab = qe212 recode a_cmarri_cohab (-9=.) label define cmarri_coh_l -8 "Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 0"No" 1"Yes" label var a_cmarri_cohab "Whether Cohabited before Current Marriage" label value a_cmarri_cohab cmarri_coh_l tab a_cmarri_cohab, mi * Duration of cohabitation before current marriage a_cmarri_cohabd *a_lcmcby4 year began cohabiting before current marriage clonevar a_cmarri_cohabd = qe213 label define cohabd_l -8 "Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 0"Below 1 Year" label var a_cmarri_cohabd "Duration of cohabitation before current marriage" label value a_cmarri_cohabd cohabd_l tab a_cmarri_cohabd, mi sum a_cmarri_cohabd if a_cmarri_cohabd>0 * Year of first marriage a_fmarri_y gen a_fmarri_y = qe605y_best label values a_fmarri_y missing_label label var a_fmarri_y "Year of first marriage" sum a_fmarri_y if a_fmarri_y >= 0 tab a_fmarri_y if a_fmarri_y <0 * Month of first marriage a_fmarri_m gen a_fmarri_m = qe605m label values a_fmarri_m missing_label label var a_fmarri_m "Month of first marriage" tab a_fmarri_m * Whether cohabited before first marriage a_fmarri_cohab gen a_fmarri_cohab = qe607 label var a_fmarri_cohab "Whether cohabited before first marriage" label value a_fmarri_cohab cmarri_coh_l tab a_fmarri_cohab, mi * End year of first marriage a_fmarri_endy //qe602y year the divorced with the first married partner //qe603y year the first married partner died. gen a_fmarri_endy = qe602y replace a_fmarri_endy = qe603y if qe603y > 0 recode a_fmarri_endy (-9=.) label var a_fmarri_endy "End year of first marriage" label value a_fmarri_endy missing_label sum a_fmarri_endy if a_fmarri_endy > 0 tab a_fmarri_endy if a_fmarri_endy < 0 * End month of first marriage a_fmarri_endm //qe602m month the divorced with the first married partner //qe603m month the first married partner died. gen a_fmarri_endm = qe602m replace a_fmarri_endm = qe603m if qe603m > 0 recode a_fmarri_endm (-9=.) label var a_fmarri_endm "End month of first marriage" label value a_fmarri_endm missing_label tab a_fmarri_endm * Reason for the end of first marriage gen a_fmarri_endreason = qe601 recode a_fmarri_endreason ( -9=.) (5=2) label var a_fmarri_endreason "Reason for the end of first marriage" label define endreason_l -8"Not Applicable" -2"Refused to Answer" -1"Don't Know" /// 1 "Divorced" 2"Widowed" label value a_fmarri_endreason endreason_l tab a_fmarri_endreason, mi * Total number of R's marriages a_marri_times /*qe1_best current marital status? qe2 Is this the first time you got married? qe201 (For those who are not in their first marriage) how many times have you been married qe310: (for those who are in cohabitation) Did you ever get married before the current cohabitating partner? qe313: For how many times did you get married before the current cohabitating partner? qe4: (for the divored) total number of marriages qe5: (for the widowed) total number of marriages*/ gen a_marri_times = . replace a_marri_times = 0 if qe1_best == 1 |(qe1_best == 3 & qe310 == 0) replace a_marri_times = 1 if qe1_best == 2 & qe2 == 1 replace a_marri_times = qe201 if qe1_best == 2 & qe2 != 1 replace a_marri_times = qe313 if qe1_best == 3 & qe310 != 0 replace a_marri_times = qe4 if qe1_best == 4 replace a_marri_times = qe5 if qe1_best == 5 label values a_marri_times missing_label label var a_marri_times "Total number of marriages" tab a_marri_times,mi * End year of last marriage a_lmarri_endy *qe402y year the divorced with the last married partner *qe403y year the last married partner died. gen a_lmarri_endy = qe402y replace a_lmarri_endy = qe403y if qe403y > 0 recode a_lmarri_endy (-9=.) label var a_lmarri_endy "End year of last marriage" label value a_lmarri_endy missing_label sum a_lmarri_endy if a_lmarri_endy > 0 tab a_lmarri_endy if a_lmarri_endy < 0 * End month of last marriage a_lmarri_endm *qe402m month the divorced with the last married partner *qe403m month the last married partner died. gen a_lmarri_endm = qe402m replace a_lmarri_endm = qe403m if qe403m > 0 recode a_lmarri_endm (-9=.) label var a_lmarri_endm "End month of month marriage" label value a_lmarri_endm missing_label tab a_lmarri_endm * In first marriage-a_firstmarry a_firstmarri *a_marriage a_marri_times gen a_firstmarri = . replace a_firstmarri = -8 if a_marri_times == -8 | a_marri_times == 0 replace a_firstmarri = -2 if a_marri_times == -2 replace a_firstmarri = -1 if a_marri_times == -1 replace a_firstmarri = 1 if a_marri_times == 1 & a_marriage == 1 replace a_firstmarri = 0 if (a_marri_times == 1 & a_marriage != 1) | /// a_marri_times >1 label var a_firstmarri "In First Marriage" label define yesno -8"Not Applicable" -2"Refused to Answer" -1"Don't Know" label value a_firstmarri yesno tab a_firstmarri, mi save File_CN, replace ***************************** *Part.6 Migration ***************************** label define province_label 11 "Beijing" 12 "Tianjin" 13 "Hebei" /// 14 "Shanxi" 15"Inner Mongolia" 21 "Liaoning" 22 "Jilin" 23 "Heilongjiang" /// 31 "Shanghai" 32 "Jiangsu" 33 "Zhejiang" /// 34 "Anhui" 35 "Fujian" 36 "Jiangxi" 37 "Shandong" /// 41 "Henan" 42 "Hubei" 43 "Hunan" 44 "Guangdong" /// 45 "Guangxi" 46 "Hainan" 50 "Chongqing" 51 "Sichuan" /// 52 "Guizhou" 53 "Yunnan" 54 "Tibet" 61 "Shaanxi" 62 "Gansu" /// 63 "Qinghai" 64 "Ningxia" 65 "Xinjiang" -8 "Not Applicable" * Place of birth of R (province/state) a_birthplace *qa102acode birth place *Residence, province gen a_birthplace = qa102acode label values a_birthplace province_label label var a_birthplace "Place of birth of R" tab a_birthplace, mi * Place of current residence of R (province/state) a_province *provcd gen a_province = provcd label values a_province province_label tab a_province, mi * Proficiency of local language a_language *qz205: Respondent's Proficiency of Mandarin *1 Very good 2 Good 3 Fair 4 Bad gen a_language = qz205 recode a_language (7 = 1) (5 6 = 2) (3 4 = 3) (1 2 =4) label define language_l -8 "Not Applicable" -2 "Refuse to Answer" -1 "Don't Know" /// 1 "Very Good" 2"Good" 3"Fair" 4"Bad" label value a_language language_l label var a_language "Proficiency of Mandarin" tab a_language,mi tab a_language if a_language >=0 save File_CN, replace ***************************** *Part.7 Housing ***************************** * House Ownership (public, subsidized(by government or employer), private, rental) a_house_owner *fd1 gen a_house_owner = . replace a_house_owner = 1 if fd1 == 1 | fd1 == 6 |fd1 == 7 replace a_house_owner = 2 if fd1 == 3 replace a_house_owner = 3 if fd1 == 2 | fd1 == 4 | fd1 == 5 |fd1 ==77 //Others replace a_house_owner = -8 if fd1 == -8 replace a_house_owner = -2 if fd1 == -2 replace a_house_owner = -1 if fd1 == -1 label define housetn_l -8 "Not Applicable" -2 "Refuse to Answer" -1 "Don't Know" /// 1 "Owned by R or R's Family" 2 "Rented" 3 "Others (inc. subsidized by gov. or employer)" label variable a_house_owner "House Ownership" label value a_house_owner housetn_l tab a_house_owner, mi * Housing purchasing price a_houseprice /*fd102 built or purchased fd104 builing cost fd106 purchase price fd112 purchase price tab fd104 if fd106>=0 |fd112 >=0 tab fd106 if fd104>=0 |fd112 >=0 tab fd112 if fd104>=0 |fd106 >=0*/ gen a_houseprice = -8 replace a_houseprice = . if fd102 == . replace a_houseprice = fd104 if fd104 >= 0 replace a_houseprice = fd106 if fd106 >= 0 replace a_houseprice = fd112 if fd112 >= 0 label value a_houseprice numeric_l label var a_houseprice "Housing pruchasing price" sum a_houseprice if a_houseprice >0 tab a_houseprice if a_houseprice <0 insp a_houseprice * Mortgage (yes or no) a_mortgage *house_debts gen a_mortgage = a_house_owner replace a_mortgage = 1 if a_house_owner == 1 & house_debts > 0 replace a_mortgage = 0 if a_house_owner == 1 & house_debts == 0 replace a_mortgage = -8 if a_house_owner >= 2 label value a_mortgage yesno label var a_mortgage "Whether have housing mortgage" tab a_mortgage, mi * Floor size (square meters)? a_housesize *fd2 gen a_housesize = fd2 label value a_housesize numeric_l label var a_housesize "Floor Size (in m2)" insp a_housesize tab a_housesize if a_housesize <0 sum a_housesize if a_housesize >0 * Year of moving in this house a_moveyear *fd3 gen a_moveyear = fd3 label value a_moveyear numeric_l label var a_moveyear "Year of Moving in This House" tab a_moveyear if a_moveyear <0 sum a_moveyear if a_moveyear >0 insp a_moveyear save File_CN, replace ***************************** *Part.8 Health and Well-being ***************************** * Birth weight (kg) a_birthweight *qa101 Birth Weight (jin) gen a_birthweight = qa101 replace a_birthweight = a_birthweight/2 if a_birthweight > 0 label var a_birthweight "Birth weight (kg)" label value a_birthweight numeric_l sum a_birthweight if a_birthweight > 0 tab a_birthweight if a_birthweight < 0 insp a_birthweight * Current body weight (kg) a_weight gen a_weight = qp2 replace a_weight = qp2/2 if qp2 > 0 label values a_weight numeric_l label var a_weight "Current body weight (kg)" sum a_weight if a_weight > 0 tab a_weight if a_weight < 0 * Current height (cm) a_height gen a_height = qp1 label values a_height numeric_l label var a_height "Current height (cm)" sum a_height if a_height > 0 tab a_height if a_height < 0 * Self-rated health status a_health gen a_health =qp3 recode a_health (1 =1 )(2=2)(3/5=3) label define health_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" /// 1" Good" 2 "Fair" 3"Bad" label value a_health health_l label var a_health "Self-rated Health Status" tab a_health, mi * Frequancy of hospitalization due to illness/injury during the past year gen a_hospi = qp601 label var a_hospi "Frequancy of hospitalization due to illness/injury during the past year" label value a_hospi numeric_l tab a_hospi * health insurance (yes or no) a_healthinsur tab a_healthinsur * Did you smoke in the last month gen a_smoking = qq2 label var a_smoking "Did you smoke in the last month" label value a_smoking yesno tab a_smoking,mi * Did you drink alcohol more than three times each week in the last month gen a_drinking = qq3 label var a_drinking "Did you drink alcohol more than three times each week in the last month" label value a_drinking yesno tab a_drinking * CES-D depression scale *qq601 Freq. of feeling depressed in the recent month gen a_depressed = qq601 recode a_depressed (-9=.) label define depress_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" /// 1" Always" 2 "Often" 3"Sometimes" 4"Seldom" 5"Never" label value a_depressed depress_l label var a_depressed "Freq. of feeling depressed" tab a_depressed, mi * Self-rated happiness gen a_happiness = qk802 label define degree_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" /// 1 "1 Low" 5 "5 High" label value a_happiness degree_l label variable a_happiness "Self-rated Degree of Happiness" tab a_happiness, mi * Self-rated life satisfaction gen a_lifesat = qm403 label define lifesat_l -8 "Not Applicable" -2 "Refused to Answer" -1"Don't Know" /// 1 "Very Dissatisfied" 2" Dissatisfied" 3"Fair" 4"Satisfied" 5 "Very Satisfied" label value a_lifesat lifesat_l label var a_lifesat "Self-rated Life Satisfaction" tab a_lifesat, mi * bmi gen a_bmi = . replace a_bmi = a_weight/(a_height/100)^2 if a_weight > 0 &a_height>0 replace a_bmi = a_weight if a_weight < 0 replace a_bmi = a_height if a_height < 0 label value a_bmi numeric_l label var a_bmi "BMI" sum a_bmi if a_bmi >0 tab a_bmi if a_bmi < 0 insp a_bmi save File_CN, replace **********************************Spouse********************************* keep pid a_urban a_employ a_birthplace a_province a_language rename pid pid_s rename a_* a_*_s save cncompute\spouse, replace use File_CN merge m:1 pid_s using cncompute\spouse drop if _merge == 2 drop _merge save File_CN, replace * Place of residence of R's spouse (urban or rural) a_urban_s *urban replace a_urban_s = -8 if mi(a_urban_s) & qe1_best != 2 replace a_urban_s = -8 if mi(a_urban_s) & tb6_a_s != 1 //spouse: living in the family label var a_urban_s "Place of residence of R's spouse (urban or rural)" label define a_urban_l -8 "Not Applicable", modify label value a_urban_s a_urban_l tab a_urban_s, mi tab a_urban_s if a_urban_s >=0 * Employment status of R's spouse a_employ_s replace a_employ_s = -8 if mi(a_employ_s) & qe1_best != 2 replace a_employ_s = -8 if mi(a_employ_s) & tb6_a_s != 1 //spouse: living in the family label var a_employ_s "Employment status of R's spouse" tab a_employ_s, mi tab a_employ_s if a_employ_s >=0 * Place of birth of R's spouse a_birthplace_s replace a_birthplace_s = -8 if mi(a_birthplace_s) & qe1_best != 2 replace a_birthplace_s = -8 if mi(a_birthplace_s) & tb6_a_s != 1 //spouse: living in the family label var a_birthplace_s "Place of birth of R's spouse" tab a_birthplace_s, mi *Place of current residence of R's spouse /* tb602acode_a_s Spouse: Place of residence - province (economically related) td7spcode_a_s Spouse: Place of resience - province (economically unrelated */ replace a_province_s = tb602acode_a_s if mi(a_province_s) & tb602acode_a_s>0 replace a_province_s = td7spcode_a_s if mi(a_province_s) replace a_province_s = -8 if mi(a_province_s) & qe1_best != 2 replace a_province_s = -8 if mi(a_province_s) & tb6_a_s != 1 label var a_province_s "Place of current residence of R's spouse" tab a_province_s * Proficiency of local language for R's spouse a_language_s replace a_language_s = -8 if mi(a_language_s) & qe1_best != 2 replace a_language_s = -8 if mi(a_language_s) & tb6_a_s != 1 label var a_language_s "Proficiency of Mandarin for R's spouse" tab a_language_s if a_language_s >0 tab a_language_s, mi keep a_* save File_CN, replace