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: Averages between dates that are different for each agent


From   "Miguel A. Duran" <[email protected]>
To   <[email protected]>
Subject   st: Averages between dates that are different for each agent
Date   Thu, 9 Jan 2014 17:21:07 +0100

Hi, Statalisters. Maybe someone could help me to solve the following
problem. In a panel dataset, I would like to calculate the average value of
a variable for each agent, but the number of periods to be considered is
different for each agent. The following example might help to understand
what I mean (and to show how my dataset is, in a simplified version,
structured):

Agent   Period      Var    Startdate   Enddate
  1              t1          11           t2               t3
  1              t2          12           t2               t3
  1              t3          13           t2               t3
  1              t4          14           t2               t3
  2              t1          21           t1               t4
  2              t2          22           t1               t4
  2              t3          23           t1               t4
  2              t4          24           t1               t4

According to what startdate and endate indicate, I would like to calculate
the average of var for agent 1 between t2 and t3, whereas for agent 2 the
period to calculate the average of var goes from t1 to t4.

Thanks in advance for your help.

Miguel.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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