Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: hourly panel data

 From Nick Cox To statalist@hsphsun2.harvard.edu Subject Re: st: hourly panel data Date Wed, 4 May 2011 01:31:22 +0100

```Let's focus on using hours as a unit.

The range in hours for each id is naturally based on the difference
between the first and last times. Range here is the number of possible
observations.

bysort id (year day hour) : gen double range =
(24 * (mdy(1,1,year[_N]) + day[_N] - 1) + hour[_N])
-
(24 * (mdy(1,1,year[1]) + day[1] - 1) + hour[1])
+ 1

The number of observed times is easier

by id : gen observed = _N

and the number of gaps is just the difference.

A gap is not present in the data. Missings are missing values present
in the data.

You should be able to build on that. But it seems that you have many
days with no observations and it would seem futile to pad out the data
with 24 empty observations in each instance.

You don't explain what "monitor" means; perhaps that is what -id- identifies.

Nick

On Tue, May 3, 2011 at 10:31 PM, Amber Pearson <amberp37@hotmail.com> wrote:

> I am trying to tell stata that my data are a panel time series. I have the following variables: id (1-120), year (2005-2007), day (1-365), hour (11-15), and value (0-67.5)
>
> The datset looks like this:
>
> id               year                 day                  hour                     value
> 1                2005                 2                     11                        23.4
> 1                2005                 25                   12                        14.5
> 1                2006                 300                 13                          6.2
> 2                2005                 151                 11                         44.0
> 2                2007                 6                    15                         13.6
> 3                2006                 45                  12                          11.3
>
>
> I want to be able to tell how many hours are missing for each day by monitor. I also want to be able to tell how many days are missing by monitor.

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