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" <[email protected]>
To   <[email protected]>
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 
[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