Announcement

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

  • Graph on proportions

    Dear Stata-users:

    I have a dataset of age, and retired people: rret ( 0 if working, 1 if retired). I have distinguished several agegroups (see age_limit variable). Now I would like to make a graph of the proportion of people not retired per agegroup. Can someone help me? I know how to create proportions (with the command: proportion rret, over(age_limit)) but I can't seem to figure out how to get this to a line.



    [CODE]
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(rret age_limit)
    . 66
    . 66
    0 57
    . 66
    . 66
    1 66
    . 66
    . 66
    . 66
    . 66
    . 66
    0 58
    1 66
    0 52
    . 66
    0 56
    . 66
    . 66
    . 66
    . 66
    . 66
    . 66
    . 66
    . 66
    . 66
    1 66
    . 66
    0 52
    0 51
    . 66
    1 66
    0 57
    . 66
    1 66
    0 61
    0 52
    . 66
    . 66
    . 66
    . 66
    0 66
    1 66
    . 66
    0 62
    0 66
    . 66
    0 57
    . 66
    . 66
    1 66
    . 66
    . 66
    . 66
    . 66
    0 58
    0 66
    . 66
    1 59
    1 66
    0 58
    . 66
    0 66
    0 61
    1 66
    . 66
    1 63
    . 66
    . 66
    1 66
    1 66
    . 66
    . 66
    0 59
    1 66
    1 66
    1 66
    0 58
    1 66
    0 53
    . 66
    . 66
    . 66
    . 66
    1 66
    1 66
    0 59
    0 58
    0 55
    . 66
    . 66
    1 66
    . 66
    . 66
    0 66
    0 66
    . 66
    . 66
    . 66
    . 66
    . 66
    end
    label values rret yesnol
    label def yesnol 0 "no", modify
    label def yesnol 1 "yes", modify





  • #2
    You just need the complement 1 - rret. In practice putting that in a new variable will lead to the simplest solutions.

    Comment


    • #3
      Dear Nick, yes, sorry I should have mentioned that I know that I can make a complement to change the definition around. But still I would like to get this in a graph and I can't seem to find the solution to that. I thought of using a twoway line but can't succeed.

      Comment


      • #4
        Code:
        egen mean_not_retired = mean(1 - rret), by(age) 
        egen tag = tag(age) 
        line mean_not_retired age if tag 
        
        ​​​​​​​

        Comment

        Working...
        X