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

st: RE: RE: Extracting data to create a new variable


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Extracting data to create a new variable
Date   Tue, 25 Jun 2002 16:39:44 -0400

> -----Original Message-----
> From: Nick Winter 
> Sent: Tuesday, June 25, 2002 4:35 PM
> To: [email protected]
> Subject: st: RE: Extracting data to create a new variable
> 
> 
> > -----Original Message-----
> > From: [email protected] 
> > [mailto:[email protected]] 
> > Sent: Tuesday, June 25, 2002 3:45 PM
> > To: [email protected]
> > Subject: st: Extracting data to create a new variable
> > 
> > 
> > Hi everyone:
> > 
> > Let's say I have the following dataset:
> > 
> > company  year    assets   liabilities
> > a                   2001   100         25
> > a                   2000    90          30
> > a                   1999    105        45
> > b                   1999     205       105
> > b                   1998    200         80
> > b                   1997    60           15
> > 
> > 
> > I wish to generate a new variable called assets1 where 
> > asset1=assets for
> > the previous year for that company.  How would I do this in 
> > Stata?  Thank
> > you for your help.
> > 
> > Christine
> 
> 	. bysort company (year): gen assets1 = assets[_n-1] if
> year==year[_n-1]-1

The -if- condition should be:

     . ... if year==year[_n-1]+1
                              ^

Nick W

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