Announcement

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

  • Generating mean by interacting categorical variables

    Hi all
    I would like to generate a new variable newvar that is the mean of the dummy variable dummy by the interaction of year and place (both categorical variables).

    I have tried using
    HTML Code:
    mean bad, over(season)
    however this only works for one variable, when I try the two together I get returned with" interactions not allowed".
    When I use just one of season or place the command works fine however this is not what I'm looking for.

    Any solution would be much appreciated
    Last edited by Ashwin Sivakumar; 24 Sep 2022, 14:43. Reason: Grammar

  • #2
    I think I figured it out:
    HTML Code:
    egen new = mean(dummy), by(year place)

    Comment


    • #3
      Thank you for closing the thread by showing the solution you found, so that others encountering a similar problem in the future can learn from your efforts.

      Your proposed solution in #2 looks correct to me.

      Comment

      Working...
      X