Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: RE: RE: dates


From   "Vania Gerova" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: RE: dates
Date   Tue, 1 Apr 2003 18:17:01 +0100

Thank you Nick! It works!
Excuse my ignorance and if not wasting your time, could you please tell me
more about 21914, I am just guessing at the moment.
V

-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Nick Cox
Sent: 01 April 2003 17:38
To: [email protected]
Subject: st: RE: RE: RE: dates


Vania Gerova
>
> thanks for the suggestions!
> 33824 = 8th August 1992 in Excel.
> My variable looks like:
>
> 33824
> 5/25/1995
> 2/27/1995
> 33610
> 5/23/1995
> 6/22/2000
> 35550
>
> and so on, 1941 cases in one long column and it's a string.

Suppose this is string variable strvar

gen date =
cond(index(strvar,"/"),date(strvar,"mdy"),real(strvar)-21914)

That is,

if strvar contains "/", treat this as an "mdy" string date;
otherwise treat it as a number and subtract 21914.

format date %dd_m_Cy

or whatever.

Nick
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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