<?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: Strange behaviour of proc lifetest with strata in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Strange-behaviour-of-proc-lifetest-with-strata/m-p/788109#M38644</link>
    <description>&lt;P&gt;When I run your example on SAS 9.4M6, I get the following output:&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-inline" image-alt="Rick_SAS_0-1641224242961.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67078i1CE756FE15831EE1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rick_SAS_0-1641224242961.png" alt="Rick_SAS_0-1641224242961.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What version of SAS are you running? Submit&lt;BR /&gt;&lt;STRONG&gt;%put &amp;amp;=SYSVLONG;&lt;BR /&gt;&lt;/STRONG&gt;and post the output that appears in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jan 2022 15:40:02 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-01-03T15:40:02Z</dc:date>
    <item>
      <title>Strange behaviour of proc lifetest with strata</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Strange-behaviour-of-proc-lifetest-with-strata/m-p/788076#M38642</link>
      <description>&lt;P&gt;I have noticed a strange behaviour when requesting a stratified hazard plot from proc lifetest.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To illustrate the problem, I have used the code and dataset from the following website:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.oarc.ucla.edu/sas/seminars/sas-survival/" target="_self"&gt;https://stats.oarc.ucla.edu/sas/seminars/sas-survival/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Specially, the code below should result in a stratified hazard plot as shown in the website:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc lifetest data=whas500 atrisk plots=hazard(bw=200) outs=outwhas500;
strata bmi(15,18.5,25,30,40);
time lenfol*fstat(0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, the plot generated is a series of connected lines, and is not stratified and does not look like the on tin the website:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HazardPlot1.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67070i0D94E0511171965F/image-size/large?v=v2&amp;amp;px=999" role="button" title="HazardPlot1.png" alt="HazardPlot1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tested this on multiple datasets with the same result, the lines are connected and not stratified.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested this on SAS 9.4 and on SAS EG 8.1 with the same result!&lt;/P&gt;
&lt;P&gt;Any other analysis, such as a stratified Kaplan Meier works perfectly fine but for hazard plots the graphs just don't look right.&lt;/P&gt;
&lt;P&gt;Could anyone please test this and let me know if they get similar results and maybe suggest a solution?&lt;/P&gt;
&lt;P&gt;kind regards&lt;/P&gt;
&lt;P&gt;Am&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 09:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Strange-behaviour-of-proc-lifetest-with-strata/m-p/788076#M38642</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2022-01-03T09:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behaviour of proc lifetest with strata</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Strange-behaviour-of-proc-lifetest-with-strata/m-p/788109#M38644</link>
      <description>&lt;P&gt;When I run your example on SAS 9.4M6, I get the following output:&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-inline" image-alt="Rick_SAS_0-1641224242961.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67078i1CE756FE15831EE1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rick_SAS_0-1641224242961.png" alt="Rick_SAS_0-1641224242961.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What version of SAS are you running? Submit&lt;BR /&gt;&lt;STRONG&gt;%put &amp;amp;=SYSVLONG;&lt;BR /&gt;&lt;/STRONG&gt;and post the output that appears in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 15:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Strange-behaviour-of-proc-lifetest-with-strata/m-p/788109#M38644</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-01-03T15:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Strange behaviour of proc lifetest with strata</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Strange-behaviour-of-proc-lifetest-with-strata/m-p/788168#M38648</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the output you requested:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SYSVLONG=9.04.01M6P110718&lt;/P&gt;
&lt;P&gt;I think I have found the cause of the problem, I have made some changes to&amp;nbsp;Stat.Lifetest.Graphics.SmoothedHazard using proc template. I went back and deleted this template to restore defaults and re-ran the code and the output looks fine now.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the code I used initially to manipulate the template:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc template;
    delete Stat.Lifetest.Graphics.ProductLimitSurvival  / store=sasuser.templat;
    delete Stat.Lifetest.Graphics.ProductLimitSurvival2 / store=sasuser.templat;
	delete Stat.Lifetest.Graphics.SmoothedHazard / store=sasuser.templat;
	delete Stat.Lifetest.Graphics.SmoothedHazard2 / store=sasuser.templat;
run;

proc template;
source  Stat.Lifetest.Graphics.SmoothedHazard;
define statgraph Stat.Lifetest.Graphics.SmoothedHazard;
   dynamic NStrata Kernel Bandwidth confLimits GroupName maxTime _byline_ _bytitle_ _byfootnote_;
   BeginGraph;
         entrytitle  "";
         layout overlay / yaxisopts=(label="Estimated Hazard Rate" shortlabel="Hazard") xaxisopts=(linearopts=(viewmax=MAXTIME));
            bandplot LimitUpper=UPPER LimitLower=LOWER x=TIME / displayTail=false modelname="Hazard" name="Confidence" LegendLabel=
               CONFLIMITS;
            seriesplot y=HAZARD x=TIME / name="Hazard";
         endlayout;
   EndGraph;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did not deal with NSRATA &amp;gt;1 and group=STRATUM correctly in the template, I should have done it this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;BeginGraph;
      if (NSTRATA=1)
         entrytitle "";
         layout overlay / yaxisopts=(label="Estimated Hazard Rate" shortlabel="Hazard") xaxisopts=(linearopts=(viewmax=MAXTIME));
            bandplot LimitUpper=UPPER LimitLower=LOWER x=TIME / displayTail=false modelname="Hazard" name="Confidence" LegendLabel=
               CONFLIMITS;
            seriesplot y=HAZARD x=TIME / name="Hazard";
            if (EXISTS(CONFLIMITS))
               DISCRETELEGEND "Confidence" / location=outside halign=center valign=bottom;
            endif;
         endlayout;
      else
         entrytitle "";
         entrytitle CONFLIMITS / textattrs=GRAPHVALUETEXT;
         layout overlay / yaxisopts=(label="Estimated Hazard Rate" shortlabel="Hazard") xaxisopts=(linearopts=(viewmax=MAXTIME));
            bandplot LimitUpper=UPPER LimitLower=LOWER x=TIME / displayTail=false group=STRATUM index=STRATUMNUM modelname="Hazard"
               display=standard datatransparency=.5;
            if (EXISTS(MAXTIME))
               seriesplot y=HAZARD x=TIME / name="Hazard" group=STRATUM index=STRATUMNUM curvelabel=BANDWIDTHLABEL
                  curvelabellocation=inside curvelabelposition=start;
            else
               seriesplot y=HAZARD x=TIME / name="Hazard" group=STRATUM index=STRATUMNUM curvelabel=BANDWIDTHLABEL
                  curvelabellocation=inside curvelabelposition=end;
            endif;
             discretelegend "Hazard" / title=GROUPNAME location=outside hAlign=center vAlign=bottom;
         endlayout;
      endif;
      if (_BYTITLE_)
         entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
      else
         if (_BYFOOTNOTE_)
            entryfootnote halign=left _BYLINE_;
         endif;
      endif;
   EndGraph;
end;                           &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now it is working correctly. Your output figure (the presence of the entry title "&lt;FONT color="#FF0000"&gt;Epanechinkov Kernel-Smoothed Hazard Function&lt;/FONT&gt;") gave me the hint and reminded me of the cause&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jan 2022 18:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Strange-behaviour-of-proc-lifetest-with-strata/m-p/788168#M38648</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2022-01-03T18:58:15Z</dc:date>
    </item>
  </channel>
</rss>

