<?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: Kaplan-Meier at-risk table not aligned with overall x-axis in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-at-risk-table-not-aligned-with-overall-x-axis/m-p/930363#M366042</link>
    <description>&lt;P&gt;You could try alternative way to get it .&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(atrisk=0 to 2500 by 500);
time ftime*Status(0);
strata diagnosis;
run;
ods select all;


title '缓解概率';
proc sgplot data=SurvivalPlot;
step x=Time y=Survival / group=Stratum lineattrs=(pattern=solid) name='a' ;
scatter x=Time y=Censored /group=Stratum markerattrs=(symbol=plus ) ;
xaxistable atrisk / x=tatrisk class=stratum colorgroup=stratum valueattrs=(weight=bold);
xaxis label='天数';
yaxis label='存活概率';
keylegend 'a'  / across=1 location=inside position=ne title='' ;
inset '+ Censored'  /  position=sw border;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1717123296328.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96881i1B99FC01308B175C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1717123296328.png" alt="Ksharp_0-1717123296328.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 31 May 2024 02:41:47 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-05-31T02:41:47Z</dc:date>
    <item>
      <title>Kaplan-Meier at-risk table not aligned with overall x-axis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-at-risk-table-not-aligned-with-overall-x-axis/m-p/930345#M366029</link>
      <description>&lt;P&gt;Hi everyone. I'm trying to add an at-risk table to my Kaplan-Meier curves. I'm using the survival macros code found &lt;A href="https://support.sas.com/documentation/onlinedoc/stat/ex_code/143/templft.html" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;If I do not use the "outside" option, everything aligns nicely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;* Bring in macro;
%ProvideSurvivalMacros
%let tatters    = textattrs=(size=14pt);
%let TitleText0 = "3-Year Post-Recurrence Survival" / textattrs=(size=14pt); 
%let TitleText1 = &amp;amp;titletext0 ;
%let TitleText2 = &amp;amp;titletext0 ;
%let yoptions = label='Overall Survival Probability' labelattrs=(size=12pt) linearopts=(viewmin=0 viewmax=1
                            tickvaluelist=(0 .2 0.4 0.6 0.8 1));
%let xoptions = label='Months from Recurrence' labelattrs=(size=12pt) linearopts=(viewmin=0 viewmax=24
							tickvaluelist=(0 6 12 18 24));;
%let StepOpts = lineattrs=(thickness=1);
%let LegendOpts = title=' ' location=inside across=1 autoalign=(TopRight) border=FALSE;
%let GraphOpts = attrpriority=none
                 DataLinePatterns=(Solid);
* 24-Apr-2024: Add number at risk;
%let AtRiskOpts =  valueattrs=(size=10pt) ;
%CompileSurvivalTemplates;
ods select survivalplot;
proc lifetest data=post  plots=survival(atrisk(maxlen=20 &lt;STRONG&gt;/*outside*/&lt;/STRONG&gt;)=0 to 24 by 6); 
	format group $recur_two.;
	time PRS3YrMonths*death3yr(0);
	strata group;
run;
ods select all;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="inside.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96877i5AD056AADACC07BF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inside.JPG" alt="inside.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I request it to be outside the plot area, it is no longer aligned.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;* Bring in macro;
%ProvideSurvivalMacros
%let tatters    = textattrs=(size=14pt);
%let TitleText0 = "3-Year Post-Recurrence Survival" / textattrs=(size=14pt); 
%let TitleText1 = &amp;amp;titletext0 ;
%let TitleText2 = &amp;amp;titletext0 ;
%let yoptions = label='Overall Survival Probability' labelattrs=(size=12pt) linearopts=(viewmin=0 viewmax=1
                            tickvaluelist=(0 .2 0.4 0.6 0.8 1));
%let xoptions = label='Months from Recurrence' labelattrs=(size=12pt) linearopts=(viewmin=0 viewmax=24
							tickvaluelist=(0 6 12 18 24));;
%let StepOpts = lineattrs=(thickness=1);
%let LegendOpts = title=' ' location=inside across=1 autoalign=(TopRight) border=FALSE;
%let GraphOpts = attrpriority=none
                 DataLinePatterns=(Solid);
* 24-Apr-2024: Add number at risk;
%let AtRiskOpts =  valueattrs=(size=10pt) ;
%CompileSurvivalTemplates;
ods select survivalplot;
proc lifetest data=post  plots=survival(atrisk(maxlen=20 &lt;STRONG&gt;outside&lt;/STRONG&gt;)=0 to 24 by 6);
	format group $recur_two.;
	time PRS3YrMonths*death3yr(0);
	strata group;
run;
ods select all;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="outside.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96878i4DACA079F40A2B3C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="outside.png" alt="outside.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the macro code, while messing around with the AtRiskLattice sections to try and fix it, I removed "xaxisopts=(display=none)." This did not fix it, but did illuminate the issue a bit. Apparently the axis for the at-risk table is not the same as the overall x-axis:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="axes.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96879iDAF7B28EDD7C2E14/image-size/medium?v=v2&amp;amp;px=400" role="button" title="axes.JPG" alt="axes.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any idea how to get these to align?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if I can provide more info.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 21:19:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-at-risk-table-not-aligned-with-overall-x-axis/m-p/930345#M366029</guid>
      <dc:creator>aliciajoyj</dc:creator>
      <dc:date>2024-05-30T21:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: Kaplan-Meier at-risk table not aligned with overall x-axis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-at-risk-table-not-aligned-with-overall-x-axis/m-p/930363#M366042</link>
      <description>&lt;P&gt;You could try alternative way to get it .&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(atrisk=0 to 2500 by 500);
time ftime*Status(0);
strata diagnosis;
run;
ods select all;


title '缓解概率';
proc sgplot data=SurvivalPlot;
step x=Time y=Survival / group=Stratum lineattrs=(pattern=solid) name='a' ;
scatter x=Time y=Censored /group=Stratum markerattrs=(symbol=plus ) ;
xaxistable atrisk / x=tatrisk class=stratum colorgroup=stratum valueattrs=(weight=bold);
xaxis label='天数';
yaxis label='存活概率';
keylegend 'a'  / across=1 location=inside position=ne title='' ;
inset '+ Censored'  /  position=sw border;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1717123296328.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96881i1B99FC01308B175C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1717123296328.png" alt="Ksharp_0-1717123296328.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 02:41:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-at-risk-table-not-aligned-with-overall-x-axis/m-p/930363#M366042</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-05-31T02:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Kaplan-Meier at-risk table not aligned with overall x-axis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-at-risk-table-not-aligned-with-overall-x-axis/m-p/930674#M366155</link>
      <description>&lt;P&gt;Thanks so much! That worked. I have spent so much time on previous projects trying to get the macro to work - using SGPLOT is sooo much easier!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I ultimately used:&lt;/P&gt;&lt;PRE&gt;* Save output to dataset;
ods select none;
proc lifetest data=post  plots=survival(atrisk(maxlen=20)=0 to 24 by 6); 
	format group $recur_two.;
	time PRS3YrMonths*death3yr(0);
	strata group;
	ods output survivalplot=postplot;
run;
ods select all;

* Only keep &amp;lt;=24 months;
data postplot2;
	set postplot;
	if tatrisk &amp;lt;= 24;
run;

title height=14pt 'Post-recurrence Survival' ;
proc sgplot data=postplot2;
	step x=Time y=Survival / group=Stratum lineattrs=(pattern=solid) name='a' ;
	scatter x=Time y=Censored /group=Stratum markerattrs=(symbol=plus ) ;
	xaxistable atrisk / x=tatrisk class=stratum colorgroup=stratum valueattrs=(size=10pt) ;
	xaxis label='Months from Recurrence'  values=(0 6 12 18 24) labelattrs=(size=12pt) valueattrs=(size=10pt);
	yaxis label='Overall Survival Probability' labelattrs=(size=12pt) valueattrs=(size=10pt);
	keylegend 'a'  / across=1 location=inside position=ne title='' ;
	inset '+ Censored'  /  position=sw border;
run;
title;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="post-recurrence survival.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96954iE47A4D2AB1C10C51/image-size/medium?v=v2&amp;amp;px=400" role="button" title="post-recurrence survival.png" alt="post-recurrence survival.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 18:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-at-risk-table-not-aligned-with-overall-x-axis/m-p/930674#M366155</guid>
      <dc:creator>aliciajoyj</dc:creator>
      <dc:date>2024-06-03T18:11:05Z</dc:date>
    </item>
  </channel>
</rss>

