Announcement

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

  • svyset , svy, store results

    Good evening everyone,

    I am working with a dataset which has individual weights. I would like to calculate the regional wage gap for descriptive statistics.
    Without weights, I would have used the following command:

    Code:
    bysort year region : egen meanf = mean(cond(Female == 1, retribuzione_sum, .)) 
    bysort year region : egen meanm = mean(cond(Female == 0, retribuzione_sum, .))
    gen diffI = (meanm - meanf) / meanm
    How can I achieve a similar outcome using svy? My main issue is generating a new variable that contains the wage gap or even just exporting the table whit diffI for each region and year.

    Many thanks in advance for your help and time

  • #2
    Although -egen- does not support -svy:-, it is not hard to calculate weighted means with it.

    Code:
    bysort year region: egen numf = total(cond(Female == 1, pwt*retribuzione_sum, .))
    bysort year region: egen denf = total(cond(Female == 1, pwt, .))
    gen wtd_meanf = numf/denf
    and analogously for males. (Evidently, replace pwt in the above by the actual name of the pweight variable.)


    Comment


    • #3
      Clyde Schechter Thank you very much for your response; it was extremely helpful!

      Comment

      Working...
      X