<?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: How do I add statistics to my SurvivalPlot? Eg: median survival time, Logrank's P-value, HR from in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/983850#M379591</link>
    <description>&lt;P&gt;Here you go:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value grpLabel 1='ALL' 2='AML low risk' 3='AML high risk';
run;

data BMT;
        input DIAGNOSIS Ftime Status Gender@@;
        label Ftime="Days";
        format Diagnosis grpLabel.;
datalines;
1       2081       0       1       1       1602    0       1
1       1496       0       1       1       1462    0       0
1       1433       0       1       1       1377    0       1
1       1330       0       1       1       996     0       1
1       226        0       0       1       1199    0       1
1       1111       0       1       1       530     0       1
1       1182       0       0       1       1167    0       0
1       418        2       1       1       383     1       1
1       276        2       0       1       104     1       1
1       609        1       1       1       172     2       0
1       487        2       1       1       662     1       1
1       194        2       0       1       230     1       0
1       526        2       1       1       122     2       1
1       129        1       0       1       74      1       1
1       122        1       0       1       86      2       1
1       466        2       1       1       192     1       1
1       109        1       1       1       55      1       0
1       1          2       1       1       107     2       1
1       110        1       0       1       332     2       1
2       2569       0       1       2       2506    0       1
2       2409       0       1       2       2218    0       1
2       1857       0       0       2       1829    0       1
2       1562       0       1       2       1470    0       1
2       1363       0       1       2       1030    0       0
2       860        0       0       2       1258    0       0
2       2246       0       0       2       1870    0       0
2       1799       0       1       2       1709    0       0
2       1674       0       1       2       1568    0       1
2       1527       0       0       2       1324    0       1
2       957        0       1       2       932     0       0
2       847        0       1       2       848     0       1
2       1850       0       0       2       1843    0       0
2       1535       0       0       2       1447    0       0
2       1384       0       0       2       414     2       1
2       2204       2       0       2       1063    2       1
2       481        2       1       2       105     2       1
2       641        2       1       2       390     2       1
2       288        2       1       2       421     1       1
2       79         2       0       2       748     1       1
2       486        1       0       2       48      2       0
2       272        1       0       2       1074    2       1
2       381        1       0       2       10      2       1
2       53         2       0       2       80      2       0
2       35         2       0       2       248     1       1
2       704        2       0       2       211     1       1
2       219        1       1       2       606     1       1
3       2640       0       1       3       2430    0       1
3       2252       0       1       3       2140    0       1
3       2133       0       0       3       1238    0       1
3       1631       0       1       3       2024    0       0
3       1345       0       1       3       1136    0       1
3       845        0       0       3       422     1       0
3       162        2       1       3       84      1       0
3       100        1       1       3       2       2       1
3       47         1       1       3       242     1       1
3       456        1       1       3       268     1       0
3       318        2       0       3       32      1       1
3       467        1       0       3       47      1       1
3       390        1       1       3       183     2       0
3       105        2       1       3       115     1       0
3       164        2       0       3       93      1       0
3       120        1       0       3       80      2       1
3       677        2       1       3       64      1       0
3       168        2       0       3       74      2       0
3       16         2       0       3       157     1       0
3       625        1       0       3       48      1       0
3       273        1       1       3       63      2       1
3       76         1       1       3       113     1       0
3       363        2       1
;
run;


ods select none;
ods output SurvivalPlot=SurvivalPlot;
proc lifetest data=bmt plots=(survival);
time ftime*Status(0);
strata diagnosis;
run;
ods select all;








data legend;
input x y treat &amp;amp; $20. event $ median &amp;amp; $40.  hr &amp;amp; $20.;
label treat='DIAGNOSIS' event='Events/Total' median='Median(95%CI)' hr='HR(95%CI)';
cards;
0 4 ALL               26/38 32.7 (15.3-45.2)   Reference
1 4 ALL               26/38 32.7 (15.3-45.2)   Reference
0 3 AML high risk     45/54 44.8 (33.8-51.5)   0.56 (0.34-0.93)
1 3 AML high risk     45/54 44.8 (33.8-51.5)   0.56 (0.34-0.93)
0 2 AML low risk      24/45 37.3 (11.9-70.1)   0.56 (0.31-1.01)
1 2 AML low risk      24/45 37.3 (11.9-70.1)   0.56 (0.31-1.01)
0 1 Logrank P-value:  0.0541 .                 + Censor
1 1 Logrank P-value:  0.0541 .                 + Censor
;
ods listing gpath="%sysfunc(pathname(work))" image_dpi=300 style=htmlblue;
ods graphics /ATTRPRIORITY=none height=80px width=450px noborder imagename='legend' outputfmt=png;
ods html exclude sgplot;   
/*generate a Legend graph*/
title;
proc sgplot data=legend noborder pad=0 noautolegend;
styleattrs datalinepatterns=(solid longdash dot dot) DATACONTRASTCOLORS=(black red green white);
series x=x y=y/group=treat lineattrs=(thickness=4);
yaxistable treat event median hr/pad=10 labelattrs=(size=16 weight=bold) valuejustify=center valueattrs=(size=14);
xaxis display=none;
yaxis display=none;
run;







%SGANNO;   
data sganno;
%SGIMAGE(image="%sysfunc(pathname(work))\legend.png",   
         drawspace="wallpercent", x1=98, y1=98,width=80,
         anchor="topright",
         border="false"         
         );
run;
ods html dpi=300;
ods graphics / reset=all ATTRPRIORITY=none;
proc sgplot data=SurvivalPlot sganno=sganno noautolegend;
styleattrs datalinepatterns=(solid longdash dot) DATACONTRASTCOLORS=(black red green);
step x=Time y=Survival / group=Stratum lineattrs=(thickness=2);
scatter x=Time y=Censored / group=Stratum markerattrs=(symbol=plus);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="tinyMceEditorKsharp_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditorKsharp_2" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditorKsharp_3" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditorKsharp_4" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/113289i33579254451D33C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot.png" alt="SGPlot.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 22 Feb 2026 14:02:39 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2026-02-22T14:02:39Z</dc:date>
    <item>
      <title>How do I add statistics to my SurvivalPlot? Eg: median survival time, Logrank's P-value, HR from Cox</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/956006#M373321</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;proc lifetest data=sascomp.adqs method=PL plots=(survival(atrisk cl) logsurv) alpha=0.05;
   time RETIME*STATUS(0);  
   strata Group;          
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is my PROC LIFETEST program, which can output a survival plot for me.&lt;/P&gt;&lt;P&gt;I've already know if I add survival(test), then I can add &lt;U&gt;&lt;STRONG&gt;log rank's P-value&lt;/STRONG&gt;&lt;/U&gt; on my plot, which is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc lifetest data=sascomp.adqs method=PL plots=(survival(test atrisk cl) logsurv) alpha=0.05;
   time RETIME*STATUS(0);  
   strata Group;          
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But I don't know how to add&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;median survival time&lt;/STRONG&gt;&lt;/U&gt; and&lt;STRONG&gt;&lt;U&gt;&amp;nbsp;HR from Cox&lt;/U&gt;&lt;/STRONG&gt;. Please help me, many thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 06:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/956006#M373321</guid>
      <dc:creator>morenayan</dc:creator>
      <dc:date>2025-01-14T06:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add statistics to my SurvivalPlot? Eg: median survival time, Logrank's P-value, HR from</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/956073#M373352</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/465252"&gt;@morenayan&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see two possible approaches: One was suggested in the 2023 post &lt;A href="https://communities.sas.com/t5/Statistical-Procedures/Kaplan-Meier-using-proc-lifetest/m-p/896953/highlight/true#M44465" target="_blank" rel="noopener"&gt;Re: Kaplan Meier using proc lifetest&lt;/A&gt; and involves reproducing the Kaplan-Meier plot with PROC SGPLOT and using &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n0lprj1bdrlrkgn1vmqnd7r6fnry.htm" target="_blank" rel="noopener"&gt;TEXT statements&lt;/A&gt;. The second approach might be simpler because it just modifies the existing&amp;nbsp;Kaplan-Meier plot (template), which is relatively easy thanks to the comprehensive macros that SAS has provided for this purpose (see&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_kaplan_sect015.htm" target="_blank" rel="noopener"&gt;Controlling the Survival Plot by Modifying Graph Templates&lt;/A&gt;). Below I provide an example using the SAS-supplied dataset SASHELP.BMT, based on the example&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_kaplan_sect030.htm" target="_blank" rel="noopener"&gt;Adding a Small Inset Table with Event Information&lt;/A&gt; from the documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data for demonstration */

data have;
set sashelp.bmt(where=(group ne 'ALL'));
run;

/* Compute statistics */

ods select none;

ods output homtests=ht quartiles=qt;
proc lifetest data=have;
time t*status(0);
strata group;
run;

ods output parameterestimates=est;
proc phreg data=have;
class group;
model t*status(0)=group / rl;
run;

ods select all;

/* Combine and format statistics */

data stats;
merge qt(where=(percent=50) drop=t:)
      est(keep=ClassVal0 h: rename=(ClassVal0=Group));
by group;
length hr $20;
if hazardratio=. then hr='Ref';
else hr=put(HazardRatio,best4.)||' ('||put(HRLowerCL,best4.)||'-'||put(HRUpperCL,best4.)||')';
run;

proc format;
value med
.='NE'
other=[4.];
run;

/* Write statistics to macro variables */

proc sql noprint;
select probchisq into :pval from ht where test like 'L%';
select group, estimate format=med., lowerlimit format=med., upperlimit format=med., hr
  into :grp1-, :med1-, :lcl1-, :ucl1-, :hr1- from stats;
quit;

/* Modify inset of Kaplan-Meier plot to contain statistics */

%ProvideSurvivalMacros /* from https://support.sas.com/documentation/onlinedoc/stat/ex_code/151/templft.html */

%let InsetOpts  = ;
%let LegendOpts = title="+ Censored" location=inside autoalign=(Bottom);

%macro StmtsBottom;
%let t = / textattrs=(weight=bold);
layout gridded / columns=3 border=TRUE autoalign=(TopRight);
  entry halign=left "Logrank  p=&amp;amp;pval"; entry " "; entry " ";
  entry " "; entry " "; entry " ";
  entry halign=left "Group" &amp;amp;t; entry "Median (95% CI)" &amp;amp;t; entry "HR (95% CI)" &amp;amp;t;
  entry halign=left "&amp;amp;grp1"; entry "&amp;amp;med1 (&amp;amp;lcl1-&amp;amp;ucl1)"; entry "&amp;amp;hr1";
  entry halign=left "&amp;amp;grp2"; entry "&amp;amp;med2 (&amp;amp;lcl2-&amp;amp;ucl2)"; entry "&amp;amp;hr2";
endlayout;
%mend;

%CompileSurvivalTemplates

/* Create the modified Kaplan-Meier plot */

ods graphics on;
proc lifetest data=have plots=(survival(test atrisk cl) logsurv);
time t*status(0);
strata group;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KM_Plot_with_statistics.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103713iE4147D46631FC760/image-size/large?v=v2&amp;amp;px=999" role="button" title="KM_Plot_with_statistics.png" alt="KM_Plot_with_statistics.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 15:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/956073#M373352</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-01-14T15:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add statistics to my SurvivalPlot? Eg: median survival time, Logrank's P-value, HR from</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/956288#M373440</link>
      <description>&lt;P&gt;HI, thanks!!!&lt;/P&gt;&lt;P&gt;i've already solved my problem perfectly by using the second solutions you've provived.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 08:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/956288#M373440</guid>
      <dc:creator>morenayan</dc:creator>
      <dc:date>2025-01-16T08:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add statistics to my SurvivalPlot? Eg: median survival time, Logrank's P-value, HR from</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/983831#M379588</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp; thank you for the solution on this post. I have a question on this . Is there any way I can move the legend inside for groups, like in the image below? I was able to get this graph generated from %newsurvmacro from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2153"&gt;@JeffMeyers&lt;/a&gt;&amp;nbsp; (&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Kaplan-Meier-Survival-Plotting-Macro-NEWSURV/ta-p/479747" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Kaplan-Meier-Survival-Plotting-Macro-NEWSURV/ta-p/479747&lt;/A&gt;).&amp;nbsp; However, I am trying to lift the code from the above macro and incorporate in your code. Is it possible?&lt;/P&gt;
&lt;DIV id="tinyMceEditorSASuserlot_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditorSASuserlot_1" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditorSASuserlot_2" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2026-02-21 163807.png" style="width: 929px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/113273i7E8615DFC605460A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2026-02-21 163807.png" alt="Screenshot 2026-02-21 163807.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Feb 2026 21:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/983831#M379588</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2026-02-21T21:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add statistics to my SurvivalPlot? Eg: median survival time, Logrank's P-value, HR from</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/983832#M379589</link>
      <description>There are two ways to incorporate the legend if you are using the gridded layout. The more manual way is to add legenditem statements and then make a discretelegend using the appropriate legend item name for that row. The second is to do a discretelegend with exclude statements to remove the items you don't want in the row, set the label to be white and size 1 so you just get the legend part. The second way is how I did it in the macro I think. A discretelegend is just another object that can go in the gridded layout cells like entry statements.</description>
      <pubDate>Sat, 21 Feb 2026 22:00:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/983832#M379589</guid>
      <dc:creator>JeffMeyers</dc:creator>
      <dc:date>2026-02-21T22:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add statistics to my SurvivalPlot? Eg: median survival time, Logrank's P-value, HR from</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/983850#M379591</link>
      <description>&lt;P&gt;Here you go:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value grpLabel 1='ALL' 2='AML low risk' 3='AML high risk';
run;

data BMT;
        input DIAGNOSIS Ftime Status Gender@@;
        label Ftime="Days";
        format Diagnosis grpLabel.;
datalines;
1       2081       0       1       1       1602    0       1
1       1496       0       1       1       1462    0       0
1       1433       0       1       1       1377    0       1
1       1330       0       1       1       996     0       1
1       226        0       0       1       1199    0       1
1       1111       0       1       1       530     0       1
1       1182       0       0       1       1167    0       0
1       418        2       1       1       383     1       1
1       276        2       0       1       104     1       1
1       609        1       1       1       172     2       0
1       487        2       1       1       662     1       1
1       194        2       0       1       230     1       0
1       526        2       1       1       122     2       1
1       129        1       0       1       74      1       1
1       122        1       0       1       86      2       1
1       466        2       1       1       192     1       1
1       109        1       1       1       55      1       0
1       1          2       1       1       107     2       1
1       110        1       0       1       332     2       1
2       2569       0       1       2       2506    0       1
2       2409       0       1       2       2218    0       1
2       1857       0       0       2       1829    0       1
2       1562       0       1       2       1470    0       1
2       1363       0       1       2       1030    0       0
2       860        0       0       2       1258    0       0
2       2246       0       0       2       1870    0       0
2       1799       0       1       2       1709    0       0
2       1674       0       1       2       1568    0       1
2       1527       0       0       2       1324    0       1
2       957        0       1       2       932     0       0
2       847        0       1       2       848     0       1
2       1850       0       0       2       1843    0       0
2       1535       0       0       2       1447    0       0
2       1384       0       0       2       414     2       1
2       2204       2       0       2       1063    2       1
2       481        2       1       2       105     2       1
2       641        2       1       2       390     2       1
2       288        2       1       2       421     1       1
2       79         2       0       2       748     1       1
2       486        1       0       2       48      2       0
2       272        1       0       2       1074    2       1
2       381        1       0       2       10      2       1
2       53         2       0       2       80      2       0
2       35         2       0       2       248     1       1
2       704        2       0       2       211     1       1
2       219        1       1       2       606     1       1
3       2640       0       1       3       2430    0       1
3       2252       0       1       3       2140    0       1
3       2133       0       0       3       1238    0       1
3       1631       0       1       3       2024    0       0
3       1345       0       1       3       1136    0       1
3       845        0       0       3       422     1       0
3       162        2       1       3       84      1       0
3       100        1       1       3       2       2       1
3       47         1       1       3       242     1       1
3       456        1       1       3       268     1       0
3       318        2       0       3       32      1       1
3       467        1       0       3       47      1       1
3       390        1       1       3       183     2       0
3       105        2       1       3       115     1       0
3       164        2       0       3       93      1       0
3       120        1       0       3       80      2       1
3       677        2       1       3       64      1       0
3       168        2       0       3       74      2       0
3       16         2       0       3       157     1       0
3       625        1       0       3       48      1       0
3       273        1       1       3       63      2       1
3       76         1       1       3       113     1       0
3       363        2       1
;
run;


ods select none;
ods output SurvivalPlot=SurvivalPlot;
proc lifetest data=bmt plots=(survival);
time ftime*Status(0);
strata diagnosis;
run;
ods select all;








data legend;
input x y treat &amp;amp; $20. event $ median &amp;amp; $40.  hr &amp;amp; $20.;
label treat='DIAGNOSIS' event='Events/Total' median='Median(95%CI)' hr='HR(95%CI)';
cards;
0 4 ALL               26/38 32.7 (15.3-45.2)   Reference
1 4 ALL               26/38 32.7 (15.3-45.2)   Reference
0 3 AML high risk     45/54 44.8 (33.8-51.5)   0.56 (0.34-0.93)
1 3 AML high risk     45/54 44.8 (33.8-51.5)   0.56 (0.34-0.93)
0 2 AML low risk      24/45 37.3 (11.9-70.1)   0.56 (0.31-1.01)
1 2 AML low risk      24/45 37.3 (11.9-70.1)   0.56 (0.31-1.01)
0 1 Logrank P-value:  0.0541 .                 + Censor
1 1 Logrank P-value:  0.0541 .                 + Censor
;
ods listing gpath="%sysfunc(pathname(work))" image_dpi=300 style=htmlblue;
ods graphics /ATTRPRIORITY=none height=80px width=450px noborder imagename='legend' outputfmt=png;
ods html exclude sgplot;   
/*generate a Legend graph*/
title;
proc sgplot data=legend noborder pad=0 noautolegend;
styleattrs datalinepatterns=(solid longdash dot dot) DATACONTRASTCOLORS=(black red green white);
series x=x y=y/group=treat lineattrs=(thickness=4);
yaxistable treat event median hr/pad=10 labelattrs=(size=16 weight=bold) valuejustify=center valueattrs=(size=14);
xaxis display=none;
yaxis display=none;
run;







%SGANNO;   
data sganno;
%SGIMAGE(image="%sysfunc(pathname(work))\legend.png",   
         drawspace="wallpercent", x1=98, y1=98,width=80,
         anchor="topright",
         border="false"         
         );
run;
ods html dpi=300;
ods graphics / reset=all ATTRPRIORITY=none;
proc sgplot data=SurvivalPlot sganno=sganno noautolegend;
styleattrs datalinepatterns=(solid longdash dot) DATACONTRASTCOLORS=(black red green);
step x=Time y=Survival / group=Stratum lineattrs=(thickness=2);
scatter x=Time y=Censored / group=Stratum markerattrs=(symbol=plus);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="tinyMceEditorKsharp_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditorKsharp_2" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditorKsharp_3" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tinyMceEditorKsharp_4" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/113289i33579254451D33C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot.png" alt="SGPlot.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Feb 2026 14:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/983850#M379591</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-02-22T14:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add statistics to my SurvivalPlot? Eg: median survival time, Logrank's P-value, HR from</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/983939#M379620</link>
      <description>&lt;P&gt;thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2153"&gt;@JeffMeyers&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;for the code. It worked like a gem.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Feb 2026 04:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-add-statistics-to-my-SurvivalPlot-Eg-median-survival/m-p/983939#M379620</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2026-02-24T04:51:32Z</dc:date>
    </item>
  </channel>
</rss>

