Dear all,
I want rel_year_nonneg to have labels as the values of display_rel_year_nonneg, which labmask is unable to do.
Basically, I want labels of rel_year_nonng to differ by cohort.
I can't use "if" condition in label define.
So, I create the a new variable as display_rel_year_nonneg as follows. However, labmask doesn't work in this case since display_rel_year_nonneg not constant within groups of rel_year_nonneg.
I appreciate your help. Thanks.
I want rel_year_nonneg to have labels as the values of display_rel_year_nonneg, which labmask is unable to do.
Basically, I want labels of rel_year_nonng to differ by cohort.
I can't use "if" condition in label define.
So, I create the a new variable as display_rel_year_nonneg as follows. However, labmask doesn't work in this case since display_rel_year_nonneg not constant within groups of rel_year_nonneg.
Code:
* Recode rel_year to be non-negative gen rel_year_nonneg = . replace rel_year_nonneg = rel_year + 2 if cohort == 2012 replace rel_year_nonneg = rel_year + 3 if cohort == 2013 * Create a helper variable for correct labeling in graphs and tables gen display_rel_year_nonneg = "" replace display_rel_year_nonneg = "-2" if rel_year_nonneg == 0 & cohort == 2012 replace display_rel_year_nonneg = "-1" if rel_year_nonneg == 1 & cohort == 2012 replace display_rel_year_nonneg = "0" if rel_year_nonneg == 2 & cohort == 2012 replace display_rel_year_nonneg = "1" if rel_year_nonneg == 3 & cohort == 2012 replace display_rel_year_nonneg = "2" if rel_year_nonneg == 4 & cohort == 2012 replace display_rel_year_nonneg = "3" if rel_year_nonneg == 5 & cohort == 2012 replace display_rel_year_nonneg = "-3" if rel_year_nonneg == 0 & cohort == 2013 replace display_rel_year_nonneg = "-2" if rel_year_nonneg == 1 & cohort == 2013 replace display_rel_year_nonneg = "-1" if rel_year_nonneg == 2 & cohort == 2013 replace display_rel_year_nonneg = "0" if rel_year_nonneg == 3 & cohort == 2013 replace display_rel_year_nonneg = "1" if rel_year_nonneg == 4 & cohort == 2013 replace display_rel_year_nonneg = "2" if rel_year_nonneg == 5 & cohort == 2013 . labmask rel_year_nonneg, values(display_rel_year_nonneg) display_rel_year_nonneg not constant within groups of rel_year_nonneg r(198); end of do-file
Comment