Announcement

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

  • twoway line code

    Hi I am trying to construct a graph with 2 y-axis and trying to label the y axis, with one y-axis being QALY and the second Y axis being Cost

    I've tried the below

    Code:
    twoway (line UKrcost age, lpattern(dash) lcolor(red)) ///
           (line ukq age, lpattern(dash) lcolor(dkgreen) yaxis(2)) ytitle("QALY")///
           (line tkrcost age, lcolor(red)) ytitle("Cost"///
           (line tkrq age, lcolor(dkgreen) yaxis(2)), ///
           legend(pos(6) rows(2)) note("Cost and QALY graphs for UKR and TKR in the male cohort")
    stata returns an error of 2 invalid name....

    can you pls help - still waiting for my chatgpt to refresh to give me some insight!

  • #2
    The punctuation is awry here. You have at least one missing parenthesis and Stata is getting confused.

    I can't test any of this as you don't give a data example -- that seems rare in your posts despite your long history on Statalist.


    This has a slightly better chance of working. I use the || syntax on the grounds that there are already many parentheses to keep track of.

    Code:
    twoway line UKrcost age, lpattern(dash) lcolor(red) ///
    || line ukq age, lpattern(dash) lcolor(dkgreen) yaxis(2) ytitle("QALY") ///
    || line tkrcost age, lcolor(red) ytitle("Cost") ///
    || line tkrq age, lcolor(dkgreen) yaxis(2) ///
    legend(pos(6) rows(2)) note("Cost and QALY graphs for UKR and TKR in the male cohort")
    I don't know whether you'd be better off with one graph for Cost and one for QALY.

    Comment

    Working...
    X