<?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: Cox regression plot - plot two lines in the same graph in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895215#M44386</link>
    <description>&lt;P&gt;Because you don't have a COVARIATES= option/data set you are getting the default behavior in the BASELINE statement of producing only the reference level of group.&amp;nbsp; You need to define a COVARIATES= option/data set where you specify both groups.&amp;nbsp; &amp;nbsp;See the example in the documentation titled "Survival Curves" for an example of using the COVARIATES= option.&amp;nbsp; I think you would also need to use the CUMHAZ= keyword on the BASELINE statement.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2023 10:40:31 GMT</pubDate>
    <dc:creator>OsoGris</dc:creator>
    <dc:date>2023-09-21T10:40:31Z</dc:date>
    <item>
      <title>Cox regression plot - plot two lines in the same graph</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895097#M44384</link>
      <description>&lt;P&gt;Hi, we have this dataset:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input ID Lastage group1 group2 Age_trt Event_age; 
datalines;
1   12  0   1   2   4
2   13  0   1   4   6
3   11  1   0   3   7
4   12  1   0   2   .
5   14  0   1   2   .
6   12  1   0   7   9
7   11  1   0   1   6nn
8   14  0   1   3   .
9   13  1   0   3   .
10  13  0   1   5   8
;
run;

data sample;
set have;
time2event = coalesce(event_age, lastage) - age_trt;
censor = missing(event_age);
if group1=1 then group=1;
else group=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Kindly &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; advised with coding to obtain KM failure plots. We are not interested in survival but in time to first event. This is the code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;ods trace on;
ods output failureplot=sp;
proc lifetest data=sample plots=survival(f)
outsurv=survival_data timelist=(0 to 24 by 2) reduceout;
strata group;
time time2event*censor(1);
run;


proc sgplot data=sp;
step x=time y=_1_survival_/group=stratum name="Percentage of patients reporting the first event";
xaxis values=(0 to 24 by 2) valueshint label="Time to event (Months)";
yaxis offsetmin=0.02 min=0 offsetmax=0.1 max=1.0 label="Percentage of patients reporting the First Event";
scatter x=time y=_1_censored_ / markerattrs=(symbol=plus) name='censored';
scatter x=time y=_1_censored_ / markerattrs=(symbol=plus) GROUP=stratum;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now, we need Cox models. I've used the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc phreg data=sample plots=(cumhaz);
class group;
model time2event*censor(1)=group;
baseline /rowid=cohort;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I used cumhaz since we are plotting a failure plot. Please correct me if this is wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My main problem is that this code only plots group 2. I checked the output data generated from this code and it also only shows data for group 2. How can the groups be showed in the same graph?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&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;</description>
      <pubDate>Wed, 20 Sep 2023 16:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895097#M44384</guid>
      <dc:creator>ANKH1</dc:creator>
      <dc:date>2023-09-20T16:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Cox regression plot - plot two lines in the same graph</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895193#M44385</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226521"&gt;@ANKH1&lt;/a&gt;&amp;nbsp;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With respect to your PROC PHREG ...&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you need to use the BASELINE statement and COVARIATES= option/data set to explicitly identify the two individual CLASS levels for plotting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a blurb from the PHREG documentation that explains why you are only getting one curve for the reference level of the CLASS variable:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"If the COVARIATES= data set is not specified, a reference set of covariates that consists of the reference levels for the CLASS variables and the average values for the continuous variables is used. For plotting more than one curve, you can use the OVERLAY=&amp;nbsp;&lt;SPAN class=" aa-argument"&gt;global-plot-option&lt;/SPAN&gt;&amp;nbsp;to group the curves in separate plots."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is from the PLOTS= option documentation found here:&lt;/SPAN&gt;&lt;BR /&gt;SAS/STAT 15.3 User's Guide&lt;BR /&gt;The PHREG Procedure&lt;BR /&gt;PROC PHREG Statement&lt;BR /&gt;Plots= option&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_syntax01.htm#statug.phreg.phrplots" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_syntax01.htm#statug.phreg.phrplots&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;So, if you create a COVARIATES= data set with the two class levels and the appropriate BASELINE statement I think you should get what you want.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data covars;
 input plt_catg @@;
datalines;
1 2
;
run;

/* And here's the BASELINE statement you then need in PROC PHREG */
         BASELINE COVARIATES=covars / ROWID=plt_catg;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think you absolutely need the ROWID option on the BASELINE statement but it doesn't look like it would hurt from reading the doc. on the BASELINE statement.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Koen&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 09:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895193#M44385</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-09-21T09:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Cox regression plot - plot two lines in the same graph</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895215#M44386</link>
      <description>&lt;P&gt;Because you don't have a COVARIATES= option/data set you are getting the default behavior in the BASELINE statement of producing only the reference level of group.&amp;nbsp; You need to define a COVARIATES= option/data set where you specify both groups.&amp;nbsp; &amp;nbsp;See the example in the documentation titled "Survival Curves" for an example of using the COVARIATES= option.&amp;nbsp; I think you would also need to use the CUMHAZ= keyword on the BASELINE statement.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 10:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895215#M44386</guid>
      <dc:creator>OsoGris</dc:creator>
      <dc:date>2023-09-21T10:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Cox regression plot - plot two lines in the same graph</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895272#M44387</link>
      <description>&lt;P&gt;Hi, thank you for looking into this. I ran the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data cov;
input group&amp;nbsp;@@;
datalines;
1 2
;
run;

proc phreg data=sample plots(overlay)=(cumhaz);
model timee2event*censor(1)=group / rl;
assess ph/resample;
baseline covariates=cov;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the graph. But I don't understand why they are exactly the same. Could you please advice?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="plot1.jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88200iAD14CE529F3C76D8/image-size/large?v=v2&amp;amp;px=999" role="button" title="plot1.jpg" alt="plot1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 14:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895272#M44387</guid>
      <dc:creator>ANKH1</dc:creator>
      <dc:date>2023-09-21T14:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Cox regression plot - plot two lines in the same graph</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895273#M44388</link>
      <description>&lt;P&gt;Thank you! The example helped. I don't understand why the two lines are the same. Tried adding cumhaz in the baseline statement but it marked error. Could you please provide how should this be added in the statement?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 14:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895273#M44388</guid>
      <dc:creator>ANKH1</dc:creator>
      <dc:date>2023-09-21T14:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cox regression plot - plot two lines in the same graph</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895352#M44391</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226521"&gt;@ANKH1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This is the graph. But I don't understand why they are exactly the same. Could you please advice?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To me the 2 lines (one for each group) are NOT the same.&lt;BR /&gt;Why do you think so?&lt;BR /&gt;They are not on top of each other.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 21:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895352#M44391</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-09-21T21:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Cox regression plot - plot two lines in the same graph</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895500#M44393</link>
      <description>&lt;P&gt;Sorry, I meant to say why do they follow the same pattern? Or could you please interpret these lines? I am new at assessing the results of Cox models.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 19:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895500#M44393</guid>
      <dc:creator>ANKH1</dc:creator>
      <dc:date>2023-09-22T19:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Cox regression plot - plot two lines in the same graph</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895645#M44401</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes , they follow the same pattern.&lt;BR /&gt;All lines (groups) can only go up (or stay flat). Because it's cumulative.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The cumulative hazard function&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;and the survival function&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;have a simple monotonic relationship, such that when the Survival function is at its maximum at the beginning of analysis time, the cumulative hazard function is at its minimum.&amp;nbsp;As time progresses, the Survival function proceeds towards it minimum, while the cumulative hazard function proceeds to its maximum.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The cumulative hazard is the negative log of the survival probabilities, i.e.&amp;nbsp;&lt;STRONG&gt;H(t)=−log(S(t))&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See here :&lt;/P&gt;
&lt;P&gt;INTRODUCTION TO SURVIVAL ANALYSIS IN SAS&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.oarc.ucla.edu/sas/seminars/sas-survival/" target="_blank"&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;You can also calculate&amp;nbsp;&lt;SPAN&gt;the cumulative hazard function using PROC LIFETEST. You don't need a Cox regression for it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR, Koen&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2023 11:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895645#M44401</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-09-25T11:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cox regression plot - plot two lines in the same graph</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895671#M44403</link>
      <description>&lt;P&gt;Thank you! This is very helpful.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2023 14:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Cox-regression-plot-plot-two-lines-in-the-same-graph/m-p/895671#M44403</guid>
      <dc:creator>ANKH1</dc:creator>
      <dc:date>2023-09-25T14:41:52Z</dc:date>
    </item>
  </channel>
</rss>

