Announcement

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

  • Histogram from loop

    Dear All

    I am using an individual level dataset having multiple variables. However, I am keeping only fem_share (female share in each occupation), ssyk_3d (3 digit occupational code), ssyk_3d_def (title of occupation), avg_loneink (wage), emp_per_ssyk (number of employees in each occupation by year) and redovar (year) variables for my purpose. The following code gives me the top and bottom 5 occupation in term of female share along with associated average monthly salary and number of employees for each top-5 and bottom-5 occupation for each year from 2003-2010. However, I want to have histogram of the number of employees and female share for top and bottom 5 occupation for each year. I would appreciate any help in this.


    forval i = 2003/2010 {
    preserve
    keep fem_share ssyk_3d ssyk_3d_def avg_loneink redovar emp_per_ssyk

    keep if redovar==`i'
    gegen group_`i'= group(fem_share)
    su group_`i', meanonly
    local max= r(max)
    forval j = 1/5 {
    local top5 = `max' -`j' + 1
    label def group1 `top5' "-`j'", modify
    }
    label val group_`i' group1
    groups group_`i' fem_share ssyk_3d ssyk_3d_def avg_loneink if group_`i' <= 5 | inrange(group_`i', `max' - 4, `max'), show(f) sepby(group_`i')
    restore
    }



    Thanks
    Zariab Hossain
    Uppsala University
Working...
X