Statalist


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

Re: st: date subtraction


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: date subtraction
Date   Wed, 17 Dec 2008 15:27:32 -0500

Hello, Moleps,

I can't reproduce the problem. My Stata responds "104". What version
of Stata are you using (version/flavor/build#)? what are the formats
of the variables? data storage types? what's the origin of the
dataset? (manually inputted, loaded as dta, converted from other file
type, etc) Try discarding formats and subtracting the dates.

generate double v1 = date("22-6-2005", "DMY")
generate double v2 = date("04-10-2005", "DMY")
format v1 %td
format v2 %td
generate v3= v2-v1
list, clean

      var1          v1          v2    v3
  1.      1   22jun2005   04oct2005   104

Best regards, Sergiy Radyakin


On Wed, Dec 17, 2008 at 2:49 PM, moleps islon <[email protected]> wrote:
> IN generating the timevariabel for a cox model I get the follwing.
> Everything is perfect, except id 83. Any idea why??
>
> gen futime=fudate-opdate
> gen pfutime=pfudate-opdate
> gen coxtime=pfutime if pfutime>futime &pfutime<.
> replace coxtime=futime if pfutime==.
> replace coxtime=pfutime if futime==.
> list opdate fudate pfudate futime pfutime coxtime
>
>
>    |    opdate      fudate     pfudate   futime   pfutime   coxtime |
>  76. | 10 Nov 04   18 Apr 05   23 May 08      159      1290      1290 |
>  77. | 25 May 04   16 Sep 04   23 May 08      114      1459      1459 |
>  78. | 24 Aug 04   01 Dec 04   30 Jun 08       99      1406      1406 |
>  79. | 28 Feb 05   22 Sep 05   26 Jun 08      206      1214      1214 |
>  80. | 06 Jan 05   13 Apr 05   15 Oct 08       97      1378      1378 |
>     |----------------------------------------------------------------|
>  81. | 10 Jan 05   18 Apr 05   15 Sep 08       98      1344      1344 |
>  82. | 14 Apr 05   06 Jun 05   25 Jun 08       53      1168      1168 |
>  83. | 22 Jun 05   04 Oct 05   24 Jun 08   -72944    -71950    -71950 |
>  84. | 15 Jan 87   10 Feb 96           .     3313         .      3313 |
>  85. | 31 Aug 92   20 Mar 94           .      566         .       566 |
>     |----------------------------------------------------------------|
>
> Regards,
> Moleps
> *
> *   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