Statalist The Stata Listserver


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

Re: st: RE: Quick Question on how to drop individualobservations


From   JEFFREY ROSEN <[email protected]>
To   [email protected]
Subject   Re: st: RE: Quick Question on how to drop individualobservations
Date   Fri, 16 Jun 2006 14:45:03 -0400

I'll have to search for a copy of the TS manual. I think your code will workk for what I need.

Thanks for all the help,

Jeff

----- Original Message -----
From: Michael Blasnik <[email protected]>
Date: Friday, June 16, 2006 2:26 pm
Subject: Re: st: RE: Quick Question on how to drop individual observations

> How about:
> 
> bysort hhold (rd ): gen incdiff=income-income[_n-1]
> by hhold (rd): replace incdiff=0 if _n==1
> 
> If you have time series data, you may want to look at ts commands 
> that deal 
> with any gaps more carefully.  You should probably read up on 
> using _n and 
> _N with -by-
> 
> Michael
> 
> ----- Original Message ----- 
> From: "JEFFREY ROSEN" <[email protected]>
> To: <[email protected]>
> Sent: Friday, June 16, 2006 2:01 PM
> Subject: Re: st: RE: Quick Question on how to drop individual 
> observations
> 
> > Thanks for the reply. This is exactly what I needed. I have one 
> more 
> > slightly related question.
> >
> > Suppose I have a data set such as:
> >
> > obs 1 hhold 1 rd 1 income 5
> > obs 2 hhold 1 rd 2 income 10
> > obs 3 hhold 1 rd 3 income 6
> > obs 4 hhold 2 rd 1 income 10
> > obs 5 hhold 2 rd 2 income 10
> > obs 5 hhold 2 rd 3 income 12
> >
> > I want to find the change in income across each round.
> >
> > So, I would like to create a variable incomedifference
> > where:
> >
> > obs 1: incomedifference = 0
> > obs 2: incomedifference = 5 (10 - 5 = 5)
> > obs 3: incomedifference = -4 (6 - 10 = -4)
> > obs 4: incomedifference = 0
> > obs 5: incomedifference = 0
> > obs 6: incomedifference = 2
> >
> > Thanks in advance,
> >
> > Jeff
> >
> >
> 
> *
> *   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index