<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Plot new data using Kaplan Meier Template - Stat.Lifetest.Graphics.ProductLimitSurvival in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326385#M11460</link>
    <description>&lt;P&gt;The data set that is used is the one that you get when you use&lt;/P&gt;
&lt;P&gt;ODS OUTPUT on the ODS name of the graph (presumably ProductLimitSurvival).&lt;/P&gt;
&lt;P&gt;For an example, see the article &lt;A href="http://blogs.sas.com/content/iml/2012/08/01/data-fro-ods-graphics.html" target="_self"&gt;"How to get data values out of ODS graphics"&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jan 2017 18:29:34 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-01-20T18:29:34Z</dc:date>
    <item>
      <title>Plot new data using Kaplan Meier Template - Stat.Lifetest.Graphics.ProductLimitSurvival</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326353#M11456</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this graph below which I created in SAS 9.2 M2 using the Kaplan Meier Template -&amp;nbsp;Stat.Lifetest.Graphics.ProductLimitSurvival. I would simply like to add another two curves to the plot (which are not related to Kaplan Meier). I would like to achieve the creation of the plot just by using the dataset that goes into proc lifetest and modifying the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Stat.Lifetest.Graphics.ProductLimitSurvival, i.e. I want to avoid outputting a dataset from Proc Lifetest and then subsequently creating a dataset that has got all the statistics that I want to plot, and then using GTL and SGRENDER to make the plot. Is that possible please? One reason why I would like to avoid using GTL and SGRender is because I think that the confidence bands will be difficult to obtain and plot. Also it would be simpler to just use the dataset that goes into SGPLOT.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It would be interesting to know which dataset goes into using this template. I think Warren Kuhfeld desribes it as a Data object in his paper -&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings13/427-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/427-2013.pdf&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/6834i7044CC741645B17E/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="kaplan.png" title="kaplan.png" width="532" height="395" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I used to create the above plot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;**** graphic options for KM plots - Changing LY colour to Red ***;
options mprint;
%macro ProductLimitStat(n=,fmt=F6.1);
   dynamic PctMedianConfid;
   %if &amp;amp;n=1 %then %do;
      dynamic NObs NEvent Median LowerMedian UpperMedian;
   %end;
   %else %do;
      %do i=1 %to &amp;amp;n;
        dynamic StrVal&amp;amp;i NObs&amp;amp;i NEvent&amp;amp;i Median&amp;amp;i LowerMedian&amp;amp;i UpperMedian&amp;amp;i;;
      %end;
   %end;

   %if &amp;amp;n=1 %then %let ncol=4;
   %else          %let ncol=5;

   layout overlay / pad=(top=5);
      layout gridded / columns=&amp;amp;ncol border=TRUE;
         %if &amp;amp;n&amp;gt;1 %then entry " ";;
         entry "No. of Patients";
         entry "Event";
         entry "Censored";
         entry "Median Survival (" PctMedianConfid " CI)";
         %do i=1 %to &amp;amp;n;
            %if &amp;amp;n=1 %then %do;
               entry NObs;
               entry NEvent;
               entry eval(NObs-NEvent);
               entry eval(put(Median,&amp;amp;fmt)) " ( "
                     eval(put(LowerMedian,&amp;amp;fmt)) " "
                     eval(put(UpperMedian,&amp;amp;fmt)) " )";
            %end;
            %else %do;
               entry halign=left StrVal&amp;amp;i;
               entry NObs&amp;amp;i;
               entry NEvent&amp;amp;i;
               entry eval(NObs&amp;amp;i-NEvent&amp;amp;i);
               entry eval(put(Median&amp;amp;i,&amp;amp;fmt)) " ( "
                     eval(put(LowerMedian&amp;amp;i,&amp;amp;fmt)) " "
                     eval(put(UpperMedian&amp;amp;i,&amp;amp;fmt)) " )";
            %end;
         %end;
      endlayout;
   endlayout;
%mend ProductLimitStat;

proc template;
source Stat.Lifetest.Graphics.ProductLimitSurvival;
define statgraph Stat.Lifetest.Graphics.ProductLimitSurvival;
   dynamic NStrata xName plotAtRisk plotCensored plotCL plotHW plotEP labelCL labelHW labelEP
      maxTime method StratumID classAtRisk plotBand plotTest GroupName yMin Transparency
      SecondTitle TestName pValue;
    mvar legtit; * Using this instead of GROUPNAME to add the title;
   BeginGraph;
      if (NSTRATA=1)
         if (EXISTS(STRATUMID))
         entrytitle "";
      else
         entrytitle "";
      endif;
      if (PLOTATRISK)
         entrytitle "" / textattrs=GRAPHVALUETEXT;
      endif;
                  layout lattice / rows=1 columns=1;
      layout overlay / xaxisopts=(shortlabel=XNAME offsetmin=.05 linearopts=(viewmax=MAXTIME))
         yaxisopts=(label="Survival Probability" shortlabel="Survival" linearopts=(viewmin=0
         viewmax=1 tickvaluelist=(0 .2 .4 .6 .8 1.0)));
         if (PLOTHW=1 AND PLOTEP=0)
            bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME / modelname="Survival" fillattrs
            =GRAPHCONFIDENCE name="HW" legendlabel=LABELHW;
         endif;
         if (PLOTHW=0 AND PLOTEP=1)
            bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME / modelname="Survival" fillattrs
            =GRAPHCONFIDENCE name="EP" legendlabel=LABELEP;
         endif;
         if (PLOTHW=1 AND PLOTEP=1)
            bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME / modelname="Survival" fillattrs
            =GRAPHDATA1 datatransparency=.55 name="HW" legendlabel=LABELHW;
         bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME / modelname="Survival" fillattrs=
            GRAPHDATA2 datatransparency=.55 name="EP" legendlabel=LABELEP;
         endif;
         if (PLOTCL=1)
            if (PLOTHW=1 OR PLOTEP=1)
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / modelname="Survival" display
            =(outline) outlineattrs=GRAPHPREDICTIONLIMITS name="CL" legendlabel=LABELCL;
         else
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / modelname="Survival"
            fillattrs=GRAPHCONFIDENCE name="CL" legendlabel=LABELCL;
         endif;
         endif;
         stepplot y=SURVIVAL x=TIME / name="Survival" rolename=(_tip1=ATRISK _tip2=EVENT) tip=(y
            x Time _tip1 _tip2) legendlabel="Survival";
         if (PLOTCENSORED=1)
            scatterplot y=CENSORED x=TIME / markerattrs=(symbol=plus) name="Censored"
            legendlabel="Censored";
         endif;
         if (PLOTCL=1 OR PLOTHW=1 OR PLOTEP=1)
            discretelegend "Censored" "CL" "HW" "EP" / location=outside halign=center;
         else
            if (PLOTCENSORED=1)
            discretelegend "Censored" / location=inside autoalign=(topright bottomleft);
         endif;
         endif;
         if (PLOTATRISK=1)
            innermargin / align=bottom;
            blockplot x=TATRISK block=ATRISK / repeatedvalues=true display=(values) valuehalign=
               start valuefitpolicy=truncate labelposition=left labelattrs=GRAPHVALUETEXT
               valueattrs=GRAPHDATATEXT (size=7pt) includemissingclass=false;
         endinnermargin;
         endif;
      endlayout;
                  columnheaders;
               %ProductLimitStat(n=1);
            endcolumnheaders;
      endlayout;

      else
         entrytitle "";
      if (EXISTS(SECONDTITLE))
         entrytitle "" / textattrs=GRAPHVALUETEXT;
      endif;
                  layout lattice / rows=1 columns=1;
      layout overlay / xaxisopts=(shortlabel=XNAME offsetmin=.05 linearopts=(viewmax=MAXTIME))
         yaxisopts=(label="Survival Probability" shortlabel="Survival" linearopts=(viewmin=0
         viewmax=1 tickvaluelist=(0 .2 .4 .6 .8 1.0)));
         if (PLOTHW)
            bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME / group=STRATUM index=STRATUMNUM
            modelname="Survival" datatransparency=Transparency;
         endif;
         if (PLOTEP)
            bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME / group=STRATUM index=STRATUMNUM
            modelname="Survival" datatransparency=Transparency;
         endif;
         if (PLOTCL)
            if (PLOTBAND)
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / group=STRATUM index=
            STRATUMNUM modelname="Survival" display=(outline);
         else
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / group=STRATUM index=
            STRATUMNUM modelname="Survival" datatransparency=Transparency;
         endif;
         endif;
         stepplot y=SURVIVAL x=TIME / group=STRATUM index=STRATUMNUM name="Survival" rolename=(
            _tip1=ATRISK _tip2=EVENT) tip=(y x Time _tip1 _tip2);
         if (PLOTCENSORED)
            scatterplot y=CENSORED x=TIME / group=STRATUM index=STRATUMNUM markerattrs=(symbol=
            plus);
         endif;
         if (PLOTATRISK)
            innermargin / align=bottom;
            blockplot x=TATRISK block=ATRISK / class=CLASSATRISK repeatedvalues=true display=(
               label values) valuehalign=start valuefitpolicy=truncate labelposition=left
               labelattrs=GRAPHVALUETEXT valueattrs=GRAPHDATATEXT (size=7pt) includemissingclass
               =false;
         endinnermargin;
         endif;
         DiscreteLegend "Survival" / title=/*GROUPNAME*/ legtit location=outside;
         if (PLOTCENSORED)
            if (PLOTTEST)
            layout gridded / rows=2 autoalign=(TOPRIGHT BOTTOMLEFT TOP BOTTOM) border=true
            BackgroundColor=GraphWalls:Color Opaque=true;
            entry "+ Censored";
            if (PVALUE &amp;lt; .0001)
               /* Removing log rank */
               /*entry TESTNAME " p " eval (PUT(PVALUE, PVALUE6.4))*/
               entry "";
            else
               /*entry TESTNAME " p=" eval (PUT(PVALUE, PVALUE6.4))*/
               entry "";
            endif;
         endlayout;
         else
            layout gridded / rows=1 autoalign=(TOPRIGHT BOTTOMLEFT TOP BOTTOM) border=true
            BackgroundColor=GraphWalls:Color Opaque=true;
            entry "+ Censored";
         endlayout;
         endif;
         else
            if (PLOTTEST)
            layout gridded / rows=1 autoalign=(TOPRIGHT BOTTOMLEFT TOP BOTTOM) border=true
            BackgroundColor=GraphWalls:Color Opaque=true;
            if (PVALUE &amp;lt; .0001)
               entry TESTNAME " p " eval (PUT(PVALUE, PVALUE6.4));
            else
               entry TESTNAME " p=" eval (PUT(PVALUE, PVALUE6.4));
            endif;
         endlayout;
         endif;
         endif;
      endlayout;
                  columnheaders;
                if (NStrata=2) %ProductLimitStat(n=2);endif;
                if (NStrata=3) %ProductLimitStat(n=3);endif;
                if (NStrata=4) %ProductLimitStat(n=4);endif;
                if (NStrata=5) %ProductLimitStat(n=5);endif;
                if (NStrata=6) %ProductLimitStat(n=6);endif;
      endcolumnheaders;
      endlayout;
      endif;
   EndGraph;
end;
run;
goptions reset = all;
ods graphics / reset = all;


*********************;
*Add this code before the lifetest.;


*********************;
*Add this code before the lifetest.;

data bmt;
  set sashelp.BMT;
  xval = 250;
  yval = 0.2;
run;


goptions reset = all;
ods graphics / reset = all imagename= "kaplan";

ods listing gpath = "C:\Users\Desktop\Helpful plots\kaplan_meier_with_new_data";

ods trace on;
proc lifetest data=bmt plots=survival(cb=hw atrisk=0 to 2500 by 500);
   time T * Status(0);
   strata Group / test=logrank adjust=sidak;
run;
ods trace off;

ods graphics off;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Many thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kriss Harris&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 17:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326353#M11456</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2017-01-20T17:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Plot new data using Kaplan Meier Template - Stat.Lifetest.Graphics.ProductLimitSurvival</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326373#M11458</link>
      <description>&lt;P&gt;You haven't actually explained what you want...&lt;/P&gt;
&lt;P&gt;How are these other curves defined? Do they have a fixed definition or are they dynamic based on the LIFETEST procedure?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If its fixed it's probably easier although it will appear on all KM plots.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Getting the data for the chart should be trivial using and ODS OUTPUT statement. .&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 18:15:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326373#M11458</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-20T18:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Plot new data using Kaplan Meier Template - Stat.Lifetest.Graphics.ProductLimitSurvival</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326376#M11459</link>
      <description>&lt;P&gt;Hi Kriss,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy Friday &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to think of examples when I'd want additional, non-KM lines on a KM plot&amp;nbsp;and I must admit I can't think of any. &amp;nbsp;I've poked around my SAS books and other Data Viz / Time Series books and I can't find any examples of what you're describing; based on the nature of the graph, I would say that the data displayed is limited to KM survival analysis. &amp;nbsp;If you can provide more detail about what other information you'd want to plot, I (or more than likely someone else) may be able to help.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Chris&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 18:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326376#M11459</guid>
      <dc:creator>DarthPathos</dc:creator>
      <dc:date>2017-01-20T18:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Plot new data using Kaplan Meier Template - Stat.Lifetest.Graphics.ProductLimitSurvival</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326385#M11460</link>
      <description>&lt;P&gt;The data set that is used is the one that you get when you use&lt;/P&gt;
&lt;P&gt;ODS OUTPUT on the ODS name of the graph (presumably ProductLimitSurvival).&lt;/P&gt;
&lt;P&gt;For an example, see the article &lt;A href="http://blogs.sas.com/content/iml/2012/08/01/data-fro-ods-graphics.html" target="_self"&gt;"How to get data values out of ODS graphics"&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 18:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326385#M11460</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-01-20T18:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Plot new data using Kaplan Meier Template - Stat.Lifetest.Graphics.ProductLimitSurvival</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326662#M11464</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your response. The Statistician wanted to plot their own curves which was obtained from a Bayesian analysis model. At first I thought that they wanted to keep the table of statistics below the graph, which automatically came from the Proc Lifetest - which is why I wanted the Proc Lifetest to automatically produce the figure and table. But they want the statistics from the Bayeisan model in the table instead, so I will just get the dataset in the right format and use GTL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 10:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326662#M11464</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2017-01-23T10:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Plot new data using Kaplan Meier Template - Stat.Lifetest.Graphics.ProductLimitSurvival</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326663#M11465</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Happy Monday &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; Thank you for your response and for poking around. The Statistician would like to plot their own curves which are obtained from a Bayesian analysis model. At first I thought that they wanted to keep the table of statistics below the graph, which automatically came from the Proc Lifetest - which is why I wanted the Proc Lifetest to automatically produce the figure and table. But they want the statistics from the Bayeisan model in the table instead, so I will just get the dataset in the right format and use GTL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for helping!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 10:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326663#M11465</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2017-01-23T10:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Plot new data using Kaplan Meier Template - Stat.Lifetest.Graphics.ProductLimitSurvival</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326664#M11466</link>
      <description>&lt;P&gt;Thank you for your response Rick &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 10:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Plot-new-data-using-Kaplan-Meier-Template-Stat-Lifetest-Graphics/m-p/326664#M11466</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2017-01-23T10:25:12Z</dc:date>
    </item>
  </channel>
</rss>

