| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: Panel Differences
Hi Alex,
I would create a new variable that uniquely identifies each observation in
turn, tsset by that, then 1st difference . Try:
gen unique = _n
tsset unique
gen d_interview=.
replace d_interview= D.interview if D.year ==0
replace d_interview = 365 - L.interview+interview if D.year !=0
*the first line just makes a variable that has the value of the observation
number (must be sorted in the right way)
*the rest just fills in the differences accounting for the year change on
the last observation in a given year
*you may have to set the first observation by hand as there is no 1st
difference
others may have more elegant solutions...
Jake
----- Original Message -----
From: "Alexander Nervedi" <[email protected]>
To: <[email protected]>
Sent: Monday, May 01, 2006 11:19 AM
Subject: st: Panel Differences
Hi,
I have data on a panle of 10 kids for 10 years observed approximately
every 3 weeks. It kind of looks like as below.
For each child I'd like to get the difference in the date of interviews.
Simple things like
gen diff = interview - L1.interview fail me since the tsset command
assumes that the day preceeding the current interview date (i,t), is a (i,
t-1) where the t-1 is not specific to the i but for anyonein the data set.
Consequently interview(i, t-1) may well be missing.
I was wondering what the simplest way would be to get the average distance
between interview dates for each of these 10 kids over the 10 year period.
thanks.
alex
ID year interview
1 1 10
1 1 47
...
1 1 365
1 2 31
1 2 62
...
1 2 340
...
1 10 342
2 1 10
...
_________________________________________________________________
Don't just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
*
* 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/
*
* 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/