Announcement

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

  • Generating individual-level mean income by occupation and year groups

    Hi all, I am trying to create a weekly income variable that contains mean incomes of individuals depending on the year and their occupation. For this I am using the following code but it's returning an error. Would there be an alternative way to achieve this?

    Code:
    egen year_occ2010 = group(year occ2010)
    egen income = mean(inctot)/52 if (year =! 2012 & year =! 2017), by(year_occ2010)
    varlist not allowed
    r(101)
    Last edited by Yatharth Garg; 09 Jan 2023, 12:40.

  • #2
    egen does not like functions. you'll have to replace after generation.

    Comment


    • #3
      Yes, you need to do it in two steps.

      This should do it:

      Code:
      egen income = mean(inctot) if (year =! 2012 & year =! 2017), by(year occ2010) 
        replace income = income / 52

      Comment


      • #4
        Thank you, your suggestions worked. I was confused why the error was varlist not allowed!

        Comment

        Working...
        X