Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: getting around tsset time variable integer restriction -Work with minutes???


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: getting around tsset time variable integer restriction -Work with minutes???
Date   Wed, 8 Feb 2006 10:34:01 -0000

To spell out the key issue a bit more: 

A set of integer times is one thing. 
Which variable type you use to store it is another. 

Using an -int- is not compulsory. In examples 
here Scott uses a -float-. I'd recommend as 
even safer using a -long- whenever the number
of times is too large for an -int-. 

There is no difficulty about this: 

gen long time = _n 

or 

bysort id (t) : gen long time = _n 

Nick 
[email protected] 

Scott Merryman
 
> Though -tsset- requires integer values, the time variable 
> does not have to
> be stored as an integer.
> 
> For example:
> 
> . set obs 1000000
> obs was 0, now 1000000
> 
> . gen time = _n
> 
> . tsset time
>         time variable:  time, 1 to 1000000
> 
> . desc
> 
> Contains data
>   obs:     1,000,000                          
>  vars:             1                          
>  size:     8,000,000 (74.6% of memory free)
> --------------------------------------------------------------
> --------------
>               storage  display     value
> variable name   type   format      label      variable label
> --------------------------------------------------------------
> --------------
> time            float  %9.0g                  
> --------------------------------------------------------------
> --------------
> Sorted by:  time
> 
> 
> One possibility would be to create a new time variable:
> 
> sort time
> gen mytime = _n
> tsset mytime
 
Zachary Byron Singer
 
> > The problem is not the units, it is the length of the 
> series.  My series
> > has over 149,000 observations and tsset wants the time 
> variable stored as
> > an integer, which limits me to a maximum of 65,000 
> observations since
> > integers cannot be smaller than -32767 or greater than 
> 32740.  Simply
> > converting half hours to minutes doesn't solve the problem. 
>  I need a way
> > to store my time variable as a long.

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