Juan Miguel gave good advice.
This is just to note that the code here can be telescoped.
gen time_in_month = 12 * real(substr(varname, 1, 2)) +
real(substr(varname, 3, 2))
Either way, checking that time_in_month is not missing and all sensible
is a good idea.
Nick
[email protected]
Villa Lora, Juan Miguel
I can see you are handling with a string variable. You might divide this
variable into two differents variables containing years and months and
multiply 12 times years thereafter:
gen year = substr(varname, 1, 2)
gen month = substr(varname, 3, 2)
destring year month, replace
gen time_in_month = (year*12) + month
See help subtr for more details.
Johannes Schoder
I am working with survival data and have the problem that my variable
survival time is in the following format:
yymm, where y represents years and m months. Instead of the yymm format
I just want to have it in months since otherwise I always have the jump
from 11 months (0011) to 1 year (0100).
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/