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" <vania.gerova@employment-studies.co.uk>
To   <statalist@hsphsun2.harvard.edu>
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: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Nick Cox
Sent: 01 April 2003 17:38
To: statalist@hsphsun2.harvard.edu
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
n.j.cox@durham.ac.uk

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