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

From |
"kelly johnson" <econometrics@hotmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Indexing Question |

Date |
Mon, 29 Aug 2005 12:10:28 -0400 |

What if I want to do the same calculation, but in a specific time period. Eg. in my data set, I want to calculate teh percentage change in X between 7/2/05-7/5/05 (for all observations with data in that time period). Thank you!

Kelly

From: Ulrich Kohler <kohler@wz-berlin.de>_________________________________________________________________

Reply-To: statalist@hsphsun2.harvard.edu

To: statalist@hsphsun2.harvard.edu

Subject: Re: st: Indexing Question

Date: Mon, 29 Aug 2005 18:00:20 +0200

. by id (date), sort: gen change = (X[_N]-X[1])/X[1] * 100

Uli

kelly johnson wrote:

> I have a question regading calculations and indexing. Below I have an

> except of a larrge data set. How can I calculate the percentage change in

> the variable X from the earliest date to the last date (e.g. in the case

> where id==1, the percentage change in X from 7/1/05-7/6/05). I want to do

> this by id for all my observations (i have thousands of obsevations and the

> date periods are of varying lengths...). I know it's of the 'by id:' type

> of statements, but I just can't get it right. Thank you.

>

> Kelly

>

>

> date id X

> 7/1/05 1 .2

> 7/2/05 1 .3

> 7/3/05 1 .2

> 7/4/05 1 .1

> 7/5/05 1 .5

> 7/6/05 1 .6

> 6/16/05 2 .4

> 6/17/05 2 .4

> 6/18/05 2 .4

> 6/19/05 2 .2

> 6/20/05 2 .1

> 6/21/05 2 .3

> 6/22/05 2 .5

> 4/11/05 3 .2

> 4/12/05 3 .8

> 4/13/05 3 .7

> 4/14/05 3 .8

> 4/15/05 3 .2

> 4/16/05 3 .2

> 4/17/05 3 .3

> 4/18/05 3 .1

> 4/16/05 3 .5

> ...

>

> _________________________________________________________________

> Express yourself instantly with MSN Messenger! Download today - it's FREE!

> http://messenger.msn.click-url.com/go/onm00200471ave/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/

--

kohler@wz-berlin.de

+49 (030) 25491-361

*

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

Is your PC infected? Get a FREE online computer virus scan from McAfeeŽ Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

*

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

**References**:**Re: st: Indexing Question***From:*Ulrich Kohler <kohler@wz-berlin.de>

- Prev by Date:
**RE: st: RE: Problem areas** - Next by Date:
**RE: st: Indexing Question** - Previous by thread:
**Re: st: Indexing Question** - Next by thread:
**RE: st: Indexing Question** - Index(es):

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