Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: format & reshape time-of-day measures


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: format & reshape time-of-day measures
Date   Sun, 17 Aug 2003 16:59:29 +0100

Steven_A Harvey

> I have a set of data from which I am interested in
> analyzing the time
> of day at which some key behaviors take place. The data was
> collected
> from weekly surveillance visits in two different waves over
> a period of
> 15 weeks each.  The form is:
>
> household (1-15)
> week (1-14)
> wave (1, 2)
> hour (13:00 23:30)
>
> I have two questions:
>
> 1.  The data was originally entered in Access where the
> hour variable
> takes the form ##:##.  When I imported the data into Stata
> v. 8 using
> StatTransfer, Stata read the hour variable as a float and
> assigned it a
> display format of %8.0g.  The values are now decimals with a range
> of .125 to .979.  How can I get Stata to recognize these
> values as a
> time-of-day and display them as ##:##?

I think you need to import time of day as a string variable. For
calculations, you may also need a numeric equivalent.

Frankly, time of day manipulations are not well supported in Stata.
See the archives for 28 January 2003 for a survey of bits and pieces
known to exist by one person.

> 2.  If I'm not mistaken, I then need to reshape the data
> from long to
> wide so that each household becomes a single case and each
> time-of-day
> measurement (wave 1, week 1-14 and wave 2, week 1-14) becomes a
> variable.  So I should end up with 24 measurements for each of 15
> cases, right?  (I currently have 368 "cases"--15 x 14 x 2
> minus some
> losses to follow-up and some censored households--each
> consisting of
> the 4 variables above.)  How can I use the reshape commands
> given that
> I have two levels of time measurements (wave & week)?

I doubt very much that you need to -reshape-. Such a wide
data structure would make most things harder and some things
well nigh impossible in Stata. The only thing that springs
to mind that would be easier is use of -egen, r*()- functions
like -rsum()-. Even there alternatives exist.

Nick
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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