Announcement

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

  • Conditional survival graph

    I am trying to make a graph on conditional survival that include several Kaplan Meier ( 5 year overall survival in patients who survived at 0,1,2 year etc), but I do not know how yo merge it in a single graph as the following example.
    Thanks so much!



    Attached Files

  • #2
    A data example with at least two separately generated graphs will help your cause. See FAQ Advice #12 for details,

    Comment


    • #3
      Dear Andrew Musau, Thank you for your reply! These is an extract of the dataset. Followup includes all patients, FOLLOW12 only includes patients who already survived 12 months, and so.

      clear
      input double Followup byte survival float(FOLLOW12 FOLLOW24 FOLLOW36 FOLLOW48 FOLLOW60)
      135.93333333333334 1 123.93333 111.93333 99.93333 87.93333 75.933334
      78.23333333333333 1 66.23333 54.23333 42.23333 30.233334 18.233334
      1.5333333333333334 1 . . . . .
      38.1 1 26.1 14.1 2.1 . .
      116.03333333333333 1 104.03333 92.03333 80.03333 68.03333 56.03333
      44.63333333333333 1 32.633335 20.633333 8.633333 . .
      34.833333333333336 1 22.833334 10.833333 . . .
      27 0 15 3 . . .
      24.333333333333332 1 12.333333 .3333333 . . .
      5.766666666666667 1 . . . . .
      127.8 1 115.8 103.8 91.8 79.8 67.8
      0 1 . . . . .
      129.56666666666666 1 117.56667 105.56667 93.56667 81.56667 69.566666
      8.533333333333333 1 . . . . .
      3.6666666666666665 1 . . . . .
      1.3 1 . . . . .
      .9666666666666667 1 . . . . .
      0 0 . . . . .
      119 1 107 95 83 71 59
      35.3 1 23.3 11.3 . . .
      0 1 . . . . .
      79.26666666666667 1 67.26667 55.26667 43.26667 31.266666 19.266666
      101.86666666666666 1 89.86667 77.86667 65.86667 53.86666 41.86666
      9.966666666666667 1 . . . . .
      20.933333333333334 1 8.933333 . . . .
      63.53333333333333 1 51.53333 39.53333 27.53333 15.533334 3.533333
      1.3333333333333333 1 . . . . .
      0 0 . . . . .
      13.666666666666666 0 1.6666666 . . . .
      39.36666666666667 0 27.366667 15.366667 3.3666666 . .
      12.266666666666667 1 .26666668 . . . .
      3.433333333333333 1 . . . . .
      1 1 . . . . .
      120.1 1 108.1 96.1 84.1 72.1 60.1
      11.333333333333334 1 . . . . .
      3.9 1 . . . . .
      111.76666666666667 1 99.76667 87.76667 75.76667 63.76667 51.76667
      49.9 1 37.9 25.9 13.9 1.9 .
      55.333333333333336 1 43.33333 31.333334 19.333334 7.333333 .
      5.3 1 . . . . .
      9.7 0 . . . . .
      12.633333333333333 1 .6333333 . . . .
      13.766666666666667 1 1.7666667 . . . .
      25.8 0 13.8 1.8 . . .
      1.3333333333333333 1 . . . . .
      25.1 1 13.1 1.1 . . .
      22.066666666666666 1 10.066667 . . . .
      2.5 1 . . . . .
      58.233333333333334 1 46.23333 34.233334 22.233334 10.233334 .
      13.2 1 1.2 . . . .
      117.16666666666667 1 105.16666 93.16666 81.16666 69.166664 57.16667
      95.23333333333333 0 83.23333 71.23333 59.23333 47.23333 35.233334
      55.43333333333333 1 43.43333 31.43333 19.43333 7.433333 .
      20.433333333333334 0 8.433333 . . . .
      3.9 1 . . . . .
      55.36666666666667 1 43.36666 31.366667 19.366667 7.366667 .
      87.16666666666667 0 75.166664 63.16667 51.16667 39.16667 27.166666
      4.366666666666666 0 . . . . .
      65.23333333333333 1 53.23333 41.23333 29.233334 17.233334 5.233333
      2.9 1 . . . . .
      50.06666666666667 1 38.066666 26.06667 14.066667 2.0666666 .
      59.03333333333333 1 47.03333 35.033333 23.03333 11.033334 .
      49.96666666666667 1 37.966667 25.96667 13.966666 1.9666667 .
      7.566666666666666 1 . . . . .
      113.76666666666667 1 101.76667 89.76667 77.76667 65.76667 53.76667
      4.3 1 . . . . .
      53.96666666666667 1 41.96667 29.96667 17.966667 5.966667 .
      51.46666666666667 1 39.46667 27.46667 15.466666 3.466667 .
      53.733333333333334 0 41.73333 29.733334 17.733334 5.733333 .
      50.06666666666667 1 38.066666 26.06667 14.066667 2.0666666 .
      4.6 1 . . . . .
      17.866666666666667 1 5.866667 . . . .
      22.433333333333334 1 10.433333 . . . .
      22.266666666666666 0 10.266666 . . . .
      49.833333333333336 1 37.833332 25.833334 13.833333 1.8333334 .
      59.1 1 47.1 35.1 23.1 11.1 .
      48.9 1 36.9 24.9 12.9 .9 .
      10.1 1 . . . . .
      13.6 1 1.6 . . . .
      29.7 0 17.7 5.7 . . .
      4.066666666666666 1 . . . . .
      16.1 1 4.1 . . . .
      1.1 1 . . . . .
      59.56666666666667 1 47.56667 35.566666 23.56667 11.566667 .
      103.96666666666667 1 91.96667 79.96667 67.96667 55.96667 43.96667
      16.866666666666667 0 4.866667 . . . .
      66.33333333333333 1 54.33333 42.33333 30.333334 18.333334 6.333333
      101.96666666666667 1 89.96667 77.96667 65.96667 53.96667 41.96667
      10.133333333333333 0 . . . . .
      48.2 1 36.2 24.2 12.2 .2 .
      70.26666666666667 1 58.26667 46.26667 34.266666 22.266666 10.266666
      17.866666666666667 0 5.866667 . . . .
      1.5666666666666667 1 . . . . .
      18.433333333333334 1 6.433333 . . . .
      1.1 1 . . . . .
      18.433333333333334 1 6.433333 . . . .
      14.533333333333333 1 2.533333 . . . .
      52.63333333333333 1 40.63334 28.633333 16.633333 4.633333 .
      4.6 1 . . . . .
      26.6 1 14.6 2.6 . . .
      end

      Comment


      • #4
        Please include the -sts- commands that generate a single graph and make sure it runs with the data enclosed.

        Comment


        • #5
          Dear Andrew Musau, Thank you for your reply! These are the commands for a simple graph.
          stset Followup , failure ( survival==0)
          sts graph

          The same for

          stset Followup if Followup>12 , failure ( survival==0)
          stset Followup if Followup>24 , failure ( survival==0)
          stset Followup if Followup>36 , failure ( survival==0)
          stset Followup if Followup>48 , failure ( survival==0)
          stset Followup if Followup>60 , failure ( survival==0)

          Comment


          • #6
            Thanks for the reproducible example. I will leave the aesthetic details to you.

            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input double Followup byte survival float(FOLLOW12 FOLLOW24 FOLLOW36 FOLLOW48 FOLLOW60)
            135.93333333333334 1 123.93333 111.93333  99.93333  87.93333 75.933334
             78.23333333333333 1  66.23333  54.23333  42.23333 30.233334 18.233334
            1.5333333333333334 1         .         .         .         .         .
                          38.1 1      26.1      14.1       2.1         .         .
            116.03333333333333 1 104.03333  92.03333  80.03333  68.03333  56.03333
             44.63333333333333 1 32.633335 20.633333  8.633333         .         .
            34.833333333333336 1 22.833334 10.833333         .         .         .
                            27 0        15         3         .         .         .
            24.333333333333332 1 12.333333  .3333333         .         .         .
             5.766666666666667 1         .         .         .         .         .
                         127.8 1     115.8     103.8      91.8      79.8      67.8
                             0 1         .         .         .         .         .
            129.56666666666666 1 117.56667 105.56667  93.56667  81.56667 69.566666
             8.533333333333333 1         .         .         .         .         .
            3.6666666666666665 1         .         .         .         .         .
                           1.3 1         .         .         .         .         .
             .9666666666666667 1         .         .         .         .         .
                             0 0         .         .         .         .         .
                           119 1       107        95        83        71        59
                          35.3 1      23.3      11.3         .         .         .
                             0 1         .         .         .         .         .
             79.26666666666667 1  67.26667  55.26667  43.26667 31.266666 19.266666
            101.86666666666666 1  89.86667  77.86667  65.86667  53.86666  41.86666
             9.966666666666667 1         .         .         .         .         .
            20.933333333333334 1  8.933333         .         .         .         .
             63.53333333333333 1  51.53333  39.53333  27.53333 15.533334  3.533333
            1.3333333333333333 1         .         .         .         .         .
                             0 0         .         .         .         .         .
            13.666666666666666 0 1.6666666         .         .         .         .
             39.36666666666667 0 27.366667 15.366667 3.3666666         .         .
            12.266666666666668 1 .26666668         .         .         .         .
             3.433333333333333 1         .         .         .         .         .
                             1 1         .         .         .         .         .
                         120.1 1     108.1      96.1      84.1      72.1      60.1
            11.333333333333334 1         .         .         .         .         .
                           3.9 1         .         .         .         .         .
            111.76666666666667 1  99.76667  87.76667  75.76667  63.76667  51.76667
                          49.9 1      37.9      25.9      13.9       1.9         .
            55.333333333333336 1  43.33333 31.333334 19.333334  7.333333         .
                           5.3 1         .         .         .         .         .
                           9.7 0         .         .         .         .         .
            12.633333333333333 1  .6333333         .         .         .         .
            13.766666666666668 1 1.7666667         .         .         .         .
                          25.8 0      13.8       1.8         .         .         .
            1.3333333333333333 1         .         .         .         .         .
                          25.1 1      13.1       1.1         .         .         .
            22.066666666666666 1 10.066667         .         .         .         .
                           2.5 1         .         .         .         .         .
            58.233333333333334 1  46.23333 34.233334 22.233334 10.233334         .
                          13.2 1       1.2         .         .         .         .
            117.16666666666667 1 105.16666  93.16666  81.16666 69.166664  57.16667
             95.23333333333333 0  83.23333  71.23333  59.23333  47.23333 35.233334
             55.43333333333333 1  43.43333  31.43333  19.43333  7.433333         .
            20.433333333333334 0  8.433333         .         .         .         .
                           3.9 1         .         .         .         .         .
             55.36666666666667 1  43.36666 31.366667 19.366667  7.366667         .
             87.16666666666667 0 75.166664  63.16667  51.16667  39.16667 27.166666
             4.366666666666666 0         .         .         .         .         .
             65.23333333333333 1  53.23333  41.23333 29.233334 17.233334  5.233333
                           2.9 1         .         .         .         .         .
             50.06666666666667 1 38.066666  26.06667 14.066667 2.0666666         .
             59.03333333333333 1  47.03333 35.033333  23.03333 11.033334         .
             49.96666666666667 1 37.966667  25.96667 13.966666 1.9666667         .
             7.566666666666666 1         .         .         .         .         .
            113.76666666666667 1 101.76667  89.76667  77.76667  65.76667  53.76667
                           4.3 1         .         .         .         .         .
             53.96666666666667 1  41.96667  29.96667 17.966667  5.966667         .
             51.46666666666667 1  39.46667  27.46667 15.466666  3.466667         .
            53.733333333333334 0  41.73333 29.733334 17.733334  5.733333         .
             50.06666666666667 1 38.066666  26.06667 14.066667 2.0666666         .
                           4.6 1         .         .         .         .         .
            17.866666666666667 1  5.866667         .         .         .         .
            22.433333333333334 1 10.433333         .         .         .         .
            22.266666666666666 0 10.266666         .         .         .         .
            49.833333333333336 1 37.833332 25.833334 13.833333 1.8333334         .
                          59.1 1      47.1      35.1      23.1      11.1         .
                          48.9 1      36.9      24.9      12.9        .9         .
                          10.1 1         .         .         .         .         .
                          13.6 1       1.6         .         .         .         .
                          29.7 0      17.7       5.7         .         .         .
             4.066666666666666 1         .         .         .         .         .
                          16.1 1       4.1         .         .         .         .
                           1.1 1         .         .         .         .         .
             59.56666666666667 1  47.56667 35.566666  23.56667 11.566667         .
            103.96666666666667 1  91.96667  79.96667  67.96667  55.96667  43.96667
            16.866666666666667 0  4.866667         .         .         .         .
             66.33333333333333 1  54.33333  42.33333 30.333334 18.333334  6.333333
            101.96666666666667 1  89.96667  77.96667  65.96667  53.96667  41.96667
            10.133333333333333 0         .         .         .         .         .
                          48.2 1      36.2      24.2      12.2        .2         .
             70.26666666666667 1  58.26667  46.26667 34.266666 22.266666 10.266666
            17.866666666666667 0  5.866667         .         .         .         .
            1.5666666666666667 1         .         .         .         .         .
            18.433333333333334 1  6.433333         .         .         .         .
                           1.1 1         .         .         .         .         .
            18.433333333333334 1  6.433333         .         .         .         .
            14.533333333333333 1  2.533333         .         .         .         .
             52.63333333333333 1  40.63334 28.633333 16.633333  4.633333         .
                           4.6 1         .         .         .         .         .
                          26.6 1      14.6       2.6         .         .         .
            end
            
            
            forval v= 12(12)60{
                stset Followup if Followup>`v' , failure ( survival==0)
                sts graph, outfile(out`v', replace) nodraw
            }
            stset Followup , failure ( survival==0)
            sts graph, outfile(out, replace) nodraw
            use out, clear
            gen which="all"
            forval v= 12(12)60{
                append using out`v'
                replace which="out`v'" if missing(which)
            }
            separate survival, by(which) veryshortlabel
            set scheme s1color
            tw (line survival? _t, sort connect(s))
            Click image for larger version

Name:	Graph.png
Views:	1
Size:	28.7 KB
ID:	1628817

            Last edited by Andrew Musau; 23 Sep 2021, 11:44.

            Comment


            • #7
              Dear Andrew Musau, Thank you for your reply! It was very helpful!!

              Comment

              Working...
              X