Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Re: converting dates from Excel .csv file


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: converting dates from Excel .csv file
Date   Fri, 29 Aug 2008 12:16:22 +0100

Read also the delicious story of Excel's deliberate bug-for-bug
compatibility: 

<http://support.microsoft.com/kb/214326> 

Nick
[email protected] 

Kit Baum


This advice is not stable across platforms on which Excel runs. Not  
all versions of Excel have the base date 1 January 1900.

I recommend ensuring that in Excel you have four-digit years in the  
display format of any date field. Then a .csv file containing such  
date fields is easily read, and those fields converted to Stata dates.

On Aug 29, 2008, at 02:33 , John wrote:

> Another trick with Excel dates (assuming you have the software) is to
> open the sheet in Excel and apply a general or numeric format to the
> date column.  This will show you that (at least for dates subsequent  
> to
> 1/1/1900) Excel uses elapsed days as well*.  All you need to do is
> subtract Stata's Day 0 in Excel's number line, 21916 (1/1/1960) from  
> the
> Excel elapsed day and you'll get a number that, once imported into
> Stata, can be formatted to show the correct date.
>
> E.G.: Date = Aug 28th, 1963
>
> Excel numeric equivalent: 23251 - 21916 = Stata's elapsed day 1335
>
>  . di  %dM_d,_CY 1335
>  August 28, 1963

*
*   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