|From||"kelly johnson" <firstname.lastname@example.org>|
|Subject||RE: st: Indexing Question|
|Date||Tue, 30 Aug 2005 10:53:30 -0400|
From: "Nick Cox" <email@example.com>_________________________________________________________________
Subject: RE: st: Indexing Question
Date: Mon, 29 Aug 2005 17:26:44 +0100
Your dates are to me ambiguous.
I'll guess your dates are month/day/year.
gen OK = !inlist(date, d(2jul2005), d(7jul2005))
bysort id (OK date) : gen pc_change = 100 * (X - X)/X if OK == 0 & OK == 0
The trickery with !inlist() is just a way to make the
sort order convenient. The OK dates will be coded 0
and sorted to the first two observations in each panel.
The result will be repeated for each observation in the panel.
Use -egen, tag()- or some other method to select just one.
Note that your example shows repeated values for
> 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!
* For searches and help try: