Announcement

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

  • combining several lines plots autmatically in one graph

    Sorry for the mass of questions today, but I´m pretty much under time pressure due to University Deadlines...
    Following Problem: I want to combine all line plots of earnings belonging to a specific Group in one graph.
    Lets say I have 200 Groups, each is defined by three key variables (Country, Age_group (5 categories), gender(dummy variable)(all three vraiables are string)).
    I have longditudanal datapoints for all these Groups.
    Now I want to combine the several Age gender Groups of one Country in one graph.
    That means I want to create Age Gender Groups. The resulting 10 categories should be combined in one graph for each country
    Since the dataset is pretty big I would like to use a Loop.
    I´ve started with the following code
    Code:
     egen Country_age_gender = group(Country Age_group gender)
    egen Age_gender = group (Age_group gender)
    encode Country, generate(country)
    sum country
    foreach i of num 1/`r(max)' {
       graph twoway line earnings
    Here I don´t know how to include the several Groups in the line plot.
    Thanks for your time, hoping the Problem is understandable

  • #2
    You can use levelsof and loop over the levels of the Country and age_gender variables. See help levelsof.
    Jorge Eduardo Pérez Pérez
    www.jorgeperezperez.com

    Comment

    Working...
    X