Hello,
I am trying to write these commands in a more concise form, is it applicable to use loops here?
I am trying to write these commands in a more concise form, is it applicable to use loops here?
creturn list
clear set obs 12 gen month = _n tokenize `c(Mons)' forval m = 1/12 { gen ``m'' = month == `m' } l, sep(6) +-------------------------------------------------------------------------------+ | month Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec | |-------------------------------------------------------------------------------| 1. | 1 1 0 0 0 0 0 0 0 0 0 0 0 | 2. | 2 0 1 0 0 0 0 0 0 0 0 0 0 | 3. | 3 0 0 1 0 0 0 0 0 0 0 0 0 | 4. | 4 0 0 0 1 0 0 0 0 0 0 0 0 | 5. | 5 0 0 0 0 1 0 0 0 0 0 0 0 | 6. | 6 0 0 0 0 0 1 0 0 0 0 0 0 | |-------------------------------------------------------------------------------| 7. | 7 0 0 0 0 0 0 1 0 0 0 0 0 | 8. | 8 0 0 0 0 0 0 0 1 0 0 0 0 | 9. | 9 0 0 0 0 0 0 0 0 1 0 0 0 | 10. | 10 0 0 0 0 0 0 0 0 0 1 0 0 | 11. | 11 0 0 0 0 0 0 0 0 0 0 1 0 | 12. | 12 0 0 0 0 0 0 0 0 0 0 0 1 | +-------------------------------------------------------------------------------+
Comment