Announcement

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

  • make graphs show varlabels instead of varnames

    Hi all,

    I have the following question for the code below. I am creating a new variable that is the mean of the variables below. I have the variables below labelled (for instance bhs_all_Act_ind1 has a varlabel of "Behavioral Health Services." Is there a way to make the mean of this variable have a label that is exactly the same so that when I do the twoway graph, the yaxis shows "Behavioral Health Services" instead of m7bhs_all_act_ind1? Thanks in advance. --CJ


    Code:
    foreach v of varlist bhs_all_act_ind1 overdose hi_ed death_this_month {
        bys qdate: egen m7`v'=mean(`v')
        twoway line m7`v' qdate, xline(`=tq(2020q1)', lpattern(dash) lcolor(black)) legend(label(1 "No Children") label(2 "Children Ages 15-16") label(3 "Children Ages 17-18")) xtitle("Quarters") plotregion(color(none)) lcolor(gray)
        graph save "`v'april_da", replace
        graph export "`v'april_da.png", as (png) replace
    }

  • #2
    Code:
    foreach v of varlist bhs_all_act_ind1 overdose hi_ed death_this_month {
        bys qdate: egen m7`v'=mean(`v')
        label var m7`v' `"`: var label `v''"'
        twoway line m7`v' qdate, xline(`=tq(2020q1)', lpattern(dash) lcolor(black)) legend(label(1 "No Children") label(2 "Children Ages 15-16") label(3 "Children Ages 17-18")) xtitle("Quarters") plotregion(color(none)) lcolor(gray)
        graph save "`v'april_da", replace
        graph export "`v'april_da.png", as (png) replace
    }
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Maarten, thank you so much. A simple solution! I apprecate it.

      Comment

      Working...
      X