Dear Statalisters,
To avoid temporary external shocks effects, I have restructure my balanced
panel data in a 5-years averages. I used the following program so far but now
that I want to try the data set in 3-years averages, I found it to be a pain
if I should type in the full numlist as before.
I would appreciate therefore any suggestion that avoids me typing the numlist.
*****************THE PROGRAM************
version 8.1
use datafilename1, clear
list year if id_1, nolab /*for identifying the number of 5-years periods
necessary -(panel of 7 countries)-*/
sort id year
capture egen tag=tag(id)
save, replace
clear
numlist "1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 6 6 6 6 6 7 7 7 7
7 8 8 8 8 8 9 9"
tokenize `r(numlist)'
local N : word count `r(numlist)'
set obs `N'
gen idfifth = .
forval i = 1 / `N' {
replace idfifth = ``i'' in `i' /*isn't possible to do that using -bysort id-?
*/
}
save datafilename2
merge datafilename2 with datafilename1
**********************END****************
By the way the above program creates only one panel i.e. for 1 of the 7
countries simply because I can't combine -in `i'- with -by- expression.
Any alternative will be greatly appreciated.
Adama
*
* 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/