Announcement

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

  • Line graph (average) with data panel filtered by gender

    Good afternoon everybody

    I need your help. I have a panel database and I want to make a graph of salary evolution but filtered for men and women. Edtoy using the following code, since it is the evolution of the average salary.

    line mean time if tag , ytitle( sueldo(units)) legend(order(2))

    But I don't know how to filter by man and woman.

  • #2
    Code:
    webuse grunfeld, clear
    gen tag= company<=6
    gen group= company<=3
    preserve
    collapse invest if tag, by(group year)
    tw line invest year if group, sort|| line invest year if !group, sort||, leg(order(1 "A" 2 "B")) xtitle("")
    restore

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	45.7 KB
ID:	1737707

    Comment


    • #3
      Maybe there is another way because I can't use the collapse command, since I am working with a total of 2 million observations and the computer is not very good at running that command

      Comment


      • #4
        2 million is by no means large, but I guess large is relative. If you use egen to generate means, you can do so by your grouping variables and tag one observation per group:

        Code:
        bysort female time: egen mean= mean(var)
        egen tag= tag(female time)

        Then

        Code:
        if tag
        if !tag
        Last edited by Andrew Musau; 19 Dec 2023, 17:57.

        Comment

        Working...
        X