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

st: RE: RE: RE: dates


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: dates
Date   Tue, 1 Apr 2003 17:38:11 +0100

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/



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