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

From |
Neil Shephard <[email protected]> |

To |
[email protected] |

Subject |
Re: st: Problem with string time and importing text files |

Date |
Thu, 14 Jan 2010 16:54:49 +0000 |

On Thu, Jan 14, 2010 at 4:40 PM, Orma B <[email protected]> wrote: > > 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. These are basic, common and fundamental tasks to using Stata and you're correct to seek how to achieve them in Stata as it will save you a lot of time and effort. Assuming your data is in a file named "mydata.csv" and that Stata is in the same current working directory as that file you can read your data in using... insheet using mydata.csv, clear For more options see -man insheet- > 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. If you could show us what you're typing (as requested in the Statalist FAQ, see URL at the bottom of each post) it would help us to know where you are going wrong. One thing you may want to consider is combining the date and time fields into one so that you have one variable that contains the elapsed date/time. Assuming the variables are called 'date' and 'time' you could achieve this with.. egen _t = concat(date time), punc(" ") gen double elapsed_time = clock(_t, "DMYhms") format %tc elapsed_time You'll probably find the pages at http://www.ats.ucla.edu/stat/stata/ very useful as well as the excellent Stata NetCourses (starting with 101), see http://www.stata.com/netcourse/ for more details. Neil -- "... no scientific worker has a fixed level of significance at which from year to year, and in all circumstances, he rejects hypotheses; he rather gives his mind to each particular case in the light of his evidence and his ideas." - Sir Ronald A. Fisher (1956) Email - [email protected] Website - http://slack.ser.man.ac.uk/ Photos - http://www.flickr.com/photos/slackline/ * * 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/

**References**:

- Prev by Date:
**st: AW: Calculating a (changing) accumulative sum** - Next by Date:
**Re: st: AW: Calculating a (changing) accumulative sum** - Previous by thread:
**st: AW: Problem with string time and importing text files** - Index(es):

© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |