Announcement

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

  • Weighted Average Issue

    I have a dataset which is broken down by year, age, education level, and region. I am trying to generate a variable for the weighted average education level in a given year in each region by age. I have tried to do this with the egen command and the wtmean function. However, when I attempt this I get an an error message of "varlist not allowed". My code is below.

    egen wtavg = wtmean(schooling) weight(qty), by (year age region)

  • #2
    Please see items 6 and 12 in the FAQ. The former explains the preference for real user names. The latter asks posters to be explicit with the source of the command. In this case, the wtmean option for egen comes from the user-written _gwtmean package.

    Your problem stems from where you place the comma. The comma should be right after wtmean(schooing).

    According to _gwtmean.ado, the full syntax of the wtmean option is as the following,
    Code:
    egen newvar = wtmean(exp), by(byvar) weight(wgt_expr)

    Comment


    • #3
      Thank you, this resolved the issue

      Comment

      Working...
      X