Announcement

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

  • How Y-axis scale number represent as percentage (for Kaplan-Meier curve graph)

    Kaplan-Meier curve.
    1. How the Y-axis scale number represent as percentage with Graph Editor (I did not find it in Graph Editor)?
    2. How to fix this in my STATA properties for any Kaplan-Meier curves? Thank you in advance!

  • #2
    Code:
    // open example data
    sysuse cancer, clear
    
    sts graph ,                                       ///
        ylab(0 "0" .25 "25" .5 "50" .75 "75" 1 "100") ///
        ytitle("survival probability (percent)")
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Maarten's advice is excellent as always. Nevertheless it may be worth flagging a general tool in this territory.

      Code:
      sysuse cancer, clear
      
      * do this once 
      ssc inst mylabels 
      
      mylabels 0(25)100, myscale(@/100) local(myla) 
      
      sts graph ,                                       ///
          ylab(`myla') ///
          ytitle("survival probability (percent)")
      The idea behind mylabels (SSC) is that you specify the labels you want to see and the mapping that yields the scale Stata is using. For percents, there is no gain as the conversion is so easy, and indeed some loss in dependence on another command, but for other transformations there can be advantages.

      Comment


      • #4
        To write code for representation in percentage?!
        Graph Editor can not do this?!
        I broke on this...
        ---------------------------
        sts graph , ///
        ylab(`myla') ///
        ytitle("survival probability (percent)") [Enter]


        . sts graph ,

        failure _d: died
        analysis time _t: studytime

        .
        . ylab(0 "0" .25 "25" .5 "50" .75 "75" 1 "100")
        command ylab is unrecognized
        r(199);

        .
        . ytitle("survival probability (percent)")
        command ytitle is unrecognized
        r(199);
        Last edited by Ted Turov; 30 Nov 2017, 08:50.

        Comment


        • #5
          I am sure Graph Editor can do this too, but I tend to avoid it whenever possible, and I suggest you do so to.

          You wrote me privately you got an error message with the ///. It is better to ask questions publicly. Anyhow, that suggest you tried to copy the code in the command window. You should not do so. Instead you need to open the .do file editor, by typing doedit, paste the commands in there, and run it from there.
          ---------------------------------
          Maarten L. Buis
          University of Konstanz
          Department of history and sociology
          box 40
          78457 Konstanz
          Germany
          http://www.maartenbuis.nl
          ---------------------------------

          Comment

          Working...
          X