Statalist


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

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


From   Johannes Schoder <[email protected]>
To   [email protected]
Subject   Re: st: RE: survival data analysis- recode survival time variable
Date   Tue, 25 Aug 2009 10:09:13 -0400

Thank you so much, I just did what you proposed yesterday, but I always had problems with the observations of the survival variable less than 4 characters. Now it works out perfect!
Tkanks!!
Johannes

Villa Lora, Juan Miguel schrieb:
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: [email protected]
[mailto:[email protected]] On Behalf Of Villa Lora,
Juan Miguel
Sent: Martes, 25 de Agosto de 2009 09:22 a.m.
To: [email protected]
Subject: FW: st: RE: survival data analysis- recode survival time
variable

-----Original Message-----
From: Johannes Schoder [mailto:[email protected]]
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: [email protected]
[mailto:[email protected]] On Behalf Of Johannes Schoder
Sent: Lunes, 24 de Agosto de 2009 04:57 p.m.
To: [email protected]
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/

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index