<?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 plot using proc sgplot - How to add lgroup variable and log rank p-value to the leg in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-plot-using-proc-sgplot-How-to-add-lgroup-variable/m-p/637581#M189506</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/140136"&gt;@Denali&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Use the &lt;A href="https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=p0hz27ehuzdd6pn0zaic6x52pkav.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;INSET statement&lt;/A&gt; to add the p-value:&lt;BR /&gt;Extend the ODS OUTPUT statement:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output Survivalplot=SurvivalPlotData HomTests=LogRank(where=(test='Log-Rank'));&lt;/CODE&gt;&lt;/PRE&gt;
Store the (formatted) p-value in a macro variable:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set LogRank;
call symputx('pval',put(probchisq,pvalue.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
Add the INSET statement to the PROC SGPLOT step:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;inset ("Log-Rank p-value"="&amp;amp;pval") / border position=topright;&lt;/CODE&gt;&lt;/PRE&gt;
Currently, this will collide with the keylegend 'c' (alternative: use &lt;FONT face="courier new,courier"&gt;position=right&lt;/FONT&gt;), but see item 2 below.&lt;/LI&gt;
&lt;LI&gt;The group name belongs to keylegend 's'. Also, to avoid the collision mentioned above, you may want to combine the keylegends 's' and 'c' (and remove the separate KEYLEGEND statement for legend 'c').&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;keylegend 's' 'c' / linelength=20 title="AKI";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Sat, 04 Apr 2020 15:13:33 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2020-04-04T15:13:33Z</dc:date>
    <item>
      <title>Kaplan-Meier plot using proc sgplot - How to add lgroup variable and log rank p-value to the legend</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-plot-using-proc-sgplot-How-to-add-lgroup-variable/m-p/637580#M189505</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a Kaplan-Meier plot using proc sgplot. Please see attached graph.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below are my 2 questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. How to add &lt;STRONG&gt;"log rank p value&lt;/STRONG&gt;" under "&lt;STRONG&gt;+Censor&lt;/STRONG&gt;"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I also tried to add "&lt;STRONG&gt;AKI&lt;/STRONG&gt;" as my group name for the legend (before No ----- and Yes ----)-&lt;/P&gt;&lt;P&gt;I thougt the adding" label&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;stratum = AKI;"&amp;nbsp; or "keylegend 'No' 'Yes' / title="AKI";&amp;nbsp;"&amp;nbsp;&lt;/STRONG&gt;but it did not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the SAS code:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*--Get survival plot data from LIFETEST procedure--*/&lt;BR /&gt;ods select none;&lt;BR /&gt;ods output Survivalplot=SurvivalPlotData;&lt;BR /&gt;proc lifetest data=two plots=survival(atrisk=5 to 20 by 2.5);&lt;BR /&gt;time Survive_year * death(0);&lt;BR /&gt;strata AKI;&lt;BR /&gt;run;&lt;BR /&gt;ods select all;&lt;/P&gt;&lt;P&gt;/*--Survival Plot with outer Risk Table using AxisTable--*/&lt;/P&gt;&lt;P&gt;ods graphics / reset width=5in height=3in ;&lt;BR /&gt;title 'Product-Limit Survival Estimates';&lt;BR /&gt;title2 h=0.8 'With Number of Subjects at Risk';&lt;BR /&gt;ods listing gpath= "H:\Biostatistics\Ihsin\Subspecialty Medicine\Renal Service\Latcha,Sheron\SAS Program" image_dpi=300 ;&lt;BR /&gt;ods graphics on/ imagefmt = tiff imagename = "Figure_AKI_Survivor_5yr" reset = index;&lt;BR /&gt;proc sgplot data=SurvivalPlotData noborder;&lt;BR /&gt;step x=time y=survival / group=stratum name='s';&lt;BR /&gt;scatter x=time y=censored / markerattrs=(symbol=plus) name='c';&lt;BR /&gt;scatter x=time y=censored / markerattrs=(symbol=plus) GROUP=stratum;&lt;BR /&gt;xaxistable atrisk / x=tatrisk location=inside class=stratum colorgroup=stratum valueattrs=(weight=bold);&lt;BR /&gt;keylegend 'c' / location=inside position=topright;&lt;BR /&gt;keylegend 's' / linelength=20;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;keylegend 'No' 'Yes' / title="AKI";&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;*controls the graph axis;&lt;BR /&gt;xaxis values=(5 to 20 by 5);&lt;BR /&gt;yaxis values=(0 to 1 by .2);&lt;BR /&gt;label time = Time (Year) stratum = AKI;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Apr 2020 14:25:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-plot-using-proc-sgplot-How-to-add-lgroup-variable/m-p/637580#M189505</guid>
      <dc:creator>Denali</dc:creator>
      <dc:date>2020-04-04T14:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Kaplan-Meier plot using proc sgplot - How to add lgroup variable and log rank p-value to the leg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-plot-using-proc-sgplot-How-to-add-lgroup-variable/m-p/637581#M189506</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/140136"&gt;@Denali&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Use the &lt;A href="https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=p0hz27ehuzdd6pn0zaic6x52pkav.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;INSET statement&lt;/A&gt; to add the p-value:&lt;BR /&gt;Extend the ODS OUTPUT statement:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output Survivalplot=SurvivalPlotData HomTests=LogRank(where=(test='Log-Rank'));&lt;/CODE&gt;&lt;/PRE&gt;
Store the (formatted) p-value in a macro variable:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set LogRank;
call symputx('pval',put(probchisq,pvalue.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
Add the INSET statement to the PROC SGPLOT step:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;inset ("Log-Rank p-value"="&amp;amp;pval") / border position=topright;&lt;/CODE&gt;&lt;/PRE&gt;
Currently, this will collide with the keylegend 'c' (alternative: use &lt;FONT face="courier new,courier"&gt;position=right&lt;/FONT&gt;), but see item 2 below.&lt;/LI&gt;
&lt;LI&gt;The group name belongs to keylegend 's'. Also, to avoid the collision mentioned above, you may want to combine the keylegends 's' and 'c' (and remove the separate KEYLEGEND statement for legend 'c').&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;keylegend 's' 'c' / linelength=20 title="AKI";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sat, 04 Apr 2020 15:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Kaplan-Meier-plot-using-proc-sgplot-How-to-add-lgroup-variable/m-p/637581#M189506</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-04-04T15:13:33Z</dc:date>
    </item>
  </channel>
</rss>

