Bookmark and Share

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 17:36:16 -0700 (PDT)

Hi, I am very new at using STATA.
I am using an unbalanced panel of the form:

Country Year VarX VarY      diff_x(new)     average_y(new)             
initial_x(new)
A           1      xA1    yA1     
.                   .                                  .
A           2      .         yA2     .                   
.                                  .
A           3      xA3    yA3      xA3-xA1       AVERAGE(yA1:yA3)     xA1
A           4      xA4    yA4      xA4-xA3       AVERAGE(yA3:yA4)     xA3
B           2     .          yB2      
.                  .                                   .
B           3     
xB3     yB3      .                  .                                   .
B           4     .          yB4      
.                  .                                   .
B           5     .          yB5      .                  
.                                   .
B           6     xB6     yB6      xB6-xB3       AVERAGE(yB3:yB6)     xB3

Basically, variable x has many missing values while y is available for all 
years.

I need to create 3 types of new variables:

1) a variable that for each country will equal the difference between two 
consecutive available x values.
2) a variable that for each country will take the value the average of all y's 
available between  two consecutive available x values.
3) a variable that for each country, for each available x takes the value of the 
previous observed 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index