Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: new variables creation with unbalanced panel
From
Laura <[email protected]>
To
[email protected]
Subject
st: new variables creation with unbalanced panel
Date
Tue, 12 Oct 2010 19:41:28 -0700 (PDT)
Hi, I am very new at using STATA. Sorry for the previous post, in which the
panel looked all wrong.
I am using an unbalanced panel of the form:
country year x y diff_x average_y initial_x
A 1 xA1 yA1
A 2 xA2 yA2 xA2-xA1 AVG(yA2:yA1) xA1
A 3 yA3
A 4 yA4
A 5 xA5 yA5 xA5-xA2 AVG(yA5:yA2) xA2
B 1 yB1
B 2 xB2 yB2
B 3 yB3
B 4 xB4 yB4 xB4-xB2 AVG(yB4:YB2) xB2
Basically, variable x has many missing values while y is available for all
years.
I need to create 3 types of new variables (as in the last 3 columns of the
table):
1) a variable that for each country will equal the difference between two
consecutive available x values.(diff_x)
2) a variable that for each country will take the value the average of all y's
available between two consecutive available x values. (average_y)
3) a variable that for each country, for each available x takes the value of the
previous observed x. (initial_x)
Any help would be much appreciated.
Thank you.
Laura
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/