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: AW: Date conversion in batch

From   "Martin Weiss" <>
To   <>
Subject   st: AW: Date conversion in batch
Date   Sun, 18 Apr 2010 17:26:40 +0200


Can you give an example what your problem looks like? So you got to the
point that you are dealing with dates that are formatted inconsistently. Can
you provide an example dataset via -input- that makes the resulting mess
clearer to the list?


-----Ursprüngliche Nachricht-----
[] Im Auftrag von Simon
Gesendet: Sonntag, 18. April 2010 14:34
Betreff: st: Date conversion in batch

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:

*   For searches and help try:

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