I am using data about households and I am interested in analyzing homeownership and mortgage rates by 2015 age cohorts.
The data I am using are drawn from a survey which started in 1997 and ended in 2017. During this period of time the survey design changed. So from 1997 until 2001 I have the age of the respondent as a continuous variable while starting from 2002 I have a categorical variable made of 15 categories:
- 0-5
- 6-14
- 15-17
- 18-24
- 25-29
- 30-34
- 35-39
- 40-44
- 45-49
- 50-54
- 55-59
- 60-64
- 65-69
- 70-74
- 75 and more
Code:
cap program drop create_agecohort program define create_agecohort args age_var year local cohort_var "cohort" cap drop cohort age_group gen cohort = `age_var'-`year'+2015 qui gen age_group = 1 if (`cohort_var' >=10 & `cohort_var' <=30) qui replace age_group = 2 if (`cohort_var' >=31 & `cohort_var' <=40) qui replace age_group = 3 if (`cohort_var' >=41 & `cohort_var' <=50) qui replace age_group = 4 if (`cohort_var' >=51 & `cohort_var' <=60) qui replace age_group = 5 if (`cohort_var' >=61 & `cohort_var' <=70) qui replace age_group = 6 if (`cohort_var' >=71 & `cohort_var' ~= .) end
0 Response to Cohort variable
Post a Comment