Announcement

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

  • Twoway Line with categorical variables

    Hi!

    I'm working with a panel data set and I'd like to make a twoway line, so I can study the trends of a categorical variable, which are complaints. However, I really don't know how to do it. I'd really appreciate your help. Nivel is the variable that I want to graph, which values are from 1 to 5.

    Code:
    clear all
    global path "/Users/fernandobastidasespinoza/Desktop/Universidad/CEP/Denuncias Ingresadas"
    cd "$path"
    
    import excel "Discriminación.xlsx", sheet("nivel_educacional_stata") firstrow
    
    grstyle init
    grstyle set plain
    
    gen qdate = quarterly(time, "YQ")
    
    format qdate %tq!Tq-CCYY
    drop time
    
    encode nivel,gen(nivel1)
    drop nivel
    rename nivel1 nivel
    xtset qdate nivel
    
    twoway (line denuncias qdate if nivel=="1") (line denuncias qdate if nivel=="2") (line denuncias qdate if nivel=="3") (line denuncias qdate if nivel=="4") (line denuncias qdate if nivel=="5")
    Thanks!
    Last edited by Fernando Bastidas; 23 Dec 2022, 10:37.

  • #2
    Use dataex to post enough data to produce the lines.

    Comment

    Working...
    X