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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: AW: Date conversion in batch


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
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?



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Simon
Gesendet: Sonntag, 18. April 2010 14:34
An: statalist@hsphsun2.harvard.edu
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:

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/


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