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

st: RE: Re: Panel data - generating variabels & looping


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: Panel data - generating variabels & looping
Date   Tue, 22 Oct 2002 10:47:21 +0100

Lee Chuntao replying to Alexander Severinsen: 
 
> I think you can run the following code:
> gen year = int(date/10000)
> gen month = int((date-year*10000)/100)
> gen day = date-10000*year-100*month
> replace date = mdy(month, day, year)
> gsort id  -date 
> by id: gen obs_num = _n
> 
> iis id 
> tis obs_num
> tsset id obs_num
> 
> by id: gen distance = l.date-date
> gen ratea = purchase/distance 
> by id: gen rateb=sum(ratea)

No problem, but see 

Is there any difference between using tsset and 
iis and tis before xt commands?
http://www.stata.com/support/faqs/stat/tsset.html


Nick 
n.j.cox@durham.ac.uk 

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