I followed this tutorial on how to get an x-axis label for my data but I'm having trouble (see picture).
tutorial: https://www.techtips.surveydesign.co...title-in-stata
I think the problem lies in that I want a triple loop to cover the third year...? Not sure what I'm missing here.
Any insights would be greatly appreciated. Thanks in advance.
<<data portion not shown>>
Code:
gen int year =yofd(date(date, "DMY")) gen byte aux=_n //from http://www.stata-journal.com/sjpdf.html?articlenum=pr0013 //follow special sequences //generate label for months token `c(Mons)' forval i = 1/36 { if `i'==1 la def month `i' "`=year[`i']' ``i''" , modify if inrange(`i',2,12) la def month `i' "``i''" , modify if `i'==13 la def month `i' "`=year[`i-12']' ``=`i'-12''" , modify if `i'>13 la def month `i' "``=`i'-12''" , modify } label value aux month twoway (line VictimNumber aux), xlabel(#36, labsize(small) /// angle(forty_five) valuel) xtitle("")
0 Response to x-axis labeling year and month, loop question
Post a Comment