Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: RE: survival data analysis- recode survival time variable


From   "Villa Lora, Juan Miguel" <JUANMIGUELV@Contractual.iadb.org>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: survival data analysis- recode survival time variable
Date   Tue, 25 Aug 2009 09:56:06 -0400

I apologize all you guys for attaching files. I propose this solution:

gen year = int(SURV/100)
tostring SURV, replace
gen month = substr(SURV,-2,.)
Replace month = SURV if month == ""

gen time_in_months = year*12 + real(month) 


If there is a telescope, I'd like to appreciate learning. Sorry about
that again.


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Villa Lora,
Juan Miguel
Sent: Martes, 25 de Agosto de 2009 09:22 a.m.
To: statalist@hsphsun2.harvard.edu
Subject: FW: st: RE: survival data analysis- recode survival time
variable

 

-----Original Message-----
From: Johannes Schoder [mailto:johannes.schoder@soi.uzh.ch]
Sent: Lunes, 24 de Agosto de 2009 05:54 p.m.
To: Villa Lora, Juan Miguel
Subject: Re: st: RE: survival data analysis- recode survival time
variable

Hi Juan,
Thank you very much for your help thats a great idea!!
However, when I run the command Stata always tells "type mismatch".
what I did:

gen year=substr(SURV, 1, 2)
**I guess this command is generating the year variable by just taking
the first to digits. And I guess here lies the problem because if the
survival time is e.g 1 year my spread sheet looks like this: 100 and not
0100. But I am totally not sure if this is the problem.
If you may allow I attached a subsample of the dataset.
Thank you so much for your help!!

Best,
Johannes




Villa Lora, Juan Miguel schrieb:
> Johanes,
> 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.
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Johannes 
> Schoder
> Sent: Lunes, 24 de Agosto de 2009 04:57 p.m.
> To: statalist@hsphsun2.harvard.edu
> Subject: st: survival data analysis- recode survival time variable
>
> Hi,
>
> 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).
>
> Thank you very much for your help!
> Johannes
> *
> *   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/
>
> *
> *   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/
>   


*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index