Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Date conversion in batch

From   Simon <>
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:

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?


*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index