Statalist


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

st: AW: Problem with string time and importing text files


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Problem with string time and importing text files
Date   Thu, 14 Jan 2010 17:47:01 +0100

<> 

Assuming your data reside in mydata.txt, this should work:


*************
clear*
insheet using mydata.txt, comma
gen str30 mydateandtime = v1 +" "+ v2
gen double mydate=clock(mydateandtime , "DMYhms")
format mydate %tc
l
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Orma B
Gesendet: Donnerstag, 14. Januar 2010 17:40
An: [email protected]
Betreff: st: Problem with string time and importing text files

Dear All,

I am new to Stata and faced a daunting twofold problem the whole
afternoon. I have several data sets (in txt format) with variables
date (ddmmyyyy), time (hhmmss) and a certain measurement. First I am
unable to import the sample data shown below in to stata. Thus I have
to use SPSS to import the data and then convert it to Stata format.
That takes my precious time and I want to use Stata for my work.
After I converted the data to stata format, I formatted the date
variable by format date %dD_m_Y and got just what I wanted, but I
failed in using the time variable.  I would appreciate if someone
would help so that I could learn for my future use.  A sample of my
data is shown below.   I am using stata 11.
27/10/2008,13:10:39,0.008
27/10/2008,13:11:39,0.017
27/10/2008,13:12:39,0.170
27/10/2008,13:13:39,0.032
27/10/2008,13:14:39,0.080
27/10/2008,13:15:39,0.009
27/10/2008,13:16:39,0.006
27/10/2008,13:17:39,0.007
27/10/2008,13:18:39,0.008
27/10/2008,13:19:39,0.011
27/10/2008,13:20:39,0.024
27/10/2008,13:21:39,0.131

Thanks

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index