/* Examples of dummy independent variables Data " cps_msa2013 : 2013 Current population survey for 3 MSA 3 MSA : NY, LA, CHICAGO */ clear all use https://bigblue.depaul.edu/jlee141/econdata/cps_data/cps_msa2013 /* 1. Creating continuous education variable Number of Years of Education */ // tablulate the educ92 tab educ92 // tablulate the educ92 without label tab educ92, nolabel gen educyr = 0 replace educyr = 1 if educ92 == 1 replace educyr = 4 if educ92 == 2 replace educyr = 6 if educ92 == 3 replace educyr = 8 if educ92 == 4 replace educyr = 9 if educ92 == 5 replace educyr = 10 if educ92 == 6 replace educyr = 11 if educ92 == 7 replace educyr = 12 if educ92 == 8 | educ92 == 9 replace educyr = 14 if educ92 == 10 | educ92 == 11 | educ92 == 12 replace educyr = 16 if educ92 == 13 replace educyr = 18 if educ92 == 14 replace educyr = 20 if educ92 == 15 replace educyr = 21 if educ92 == 16 /* 2. Creating simple dummy variable Here are some examples to create simple dummy variables */ gen young = 0 replace young = 1 if age < 25 gen retired_age = age > 65 gen retired_man = (age > 65 & female == 0 ) /* 3. Creating multiple dummy variables Here are some examples to create multiple dummy variables wbho (white, black, hispanic, others) -> generate four dummy variables (race1, race2, race3, race4) */ tab wbho tab wbho, gen(race) sum race1-race4 /* 4. Regression using dummy and factor varibles */ keep if hrwage < 1000 keep hrwage educ92 educyr female race1 race2 race3 race4 wbho drop if (educ92 == . | wbho == . | female == .) regr hrwage educyr female eststo regr hrwage educyr female race2-race4 eststo regr hrwage educyr female i.wbho eststo esttab, r2 ar2