Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Computing averages in panel data with missing observations

    Hello everybody!

    I would kindly like to ask you a very quick question:

    I have a panel data, and for a certain variable (let's say var_1) I need to calculate the average for each ID:

    the code: " by ID: egen MEAN_var_1 = mean(var_1) " provides for this, but the problem is that in the computation of the average, it takes into account also the missing observations.

    Is there a way to perform the same average but without considering missing observations?

    Many thanks!

    Kodi

  • #2
    Let's back up here.

    Any mean in Stata ignores missing values (not observations). The mean of 1, 2, 3, missing, missing, ... will be reported as 2.

    So, egen is already doing what you want. In fact, what do you think it is doing that you do not want?

    If missing means zero, you need to edit your data.
    Last edited by Nick Cox; 14 Dec 2017, 07:10.

    Comment


    • #3
      Sorry, you are right Nick!

      Thanks!

      Comment

      Working...
      X