Statalist The Stata Listserver


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

st: Importing dates from Excel


From   "Hugh Colaco" <[email protected]>
To   statalist <[email protected]>
Subject   st: Importing dates from Excel
Date   Sun, 7 May 2006 08:44:12 -0400

Hi,

I have 7 date columns in my master file in the "float" format and need
to constantly update the date info in the master file since some obs
have missing dates. To do this, I create a new using data file with
the updated dates and then merge into the master file. The problem is
that the using data file has dates in the "string" format since I
export dates from Excel in the mm/dd/yyyy format. So, each time I have
to go through 7 different iterations of the program below to change
date formats in the using data file so I can merge it correctly in the
master file in the "float" format.

For example, assume one of my 7 date variables in the master file is
called bdate. I then have to use

. generate bdate1 = date(bdate, "mdy")
   . format bdate1 %d
.rename bdate1 bdate

............to change it into a "float" storage type.

I have to do this for each of the 7 dates everytime I want to update
missing date info in my master file.

Is there a faster way? Can I format the dates in Excel in such a way
that the using data file will import the dates correctly in the
"float" format? I need the date in the float format because I have to
calculate no of days between dates. My master file has dates in the
form "08apr2006", for example.

Thanks,

Hugh

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