Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Date conversion in batch


From   Simon <scmoore.lists@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Date conversion in batch
Date   Sun, 18 Apr 2010 13:33:40 +0100

Dear Statalist,

I have been sent a load of excel files that I want to combine into one Stata file for analysis. First I use Roger Newson's stcmd with Stat-transfer to convert the files to Stata files:

clear
cd "`dir'"
stcmd *.xls *.dta /y

and then use Nick Cox's -fs- to

set obs 0
g age = .
g date = ""

fs *.dta
foreach f in `r(files)' {
local fn = "`dir'\`f'"
append using "`fn'"
}

My problem is that date, coming from excel, is all over the place. There's the text version of dd/mm/yyyy and the excel version of dd/mm/yyyy and then various other formats including ddmmyy and ddmmyyyy.

Just wondering if anyone had come across something similar and whether there is an easy solution - or am I destined to do this all by hand?

Simon


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