<?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 Difference in STATA and SAS results for Cox regression in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-STATA-and-SAS-results-for-Cox-regression/m-p/506170#M26018</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to understand why my regressions give me different results when I run the models in SAS or STATA. I am a new SAS user and I am trying to do survival analysis for the first time with SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this point, I have to produce Cox regressions and as I do not know very much abour SAS, I compare the results in SAS with my results from STATA to make sure that I have done the good thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of my dataset would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id time1 event1 weight independent_v1 independent_v2;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 0 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 1 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 2 0 0.8 0 0&lt;/P&gt;&lt;P&gt;1 3 0 0.8 0 0&lt;/P&gt;&lt;P&gt;1 4 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 5 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 6 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 7 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 8 0 0.8 0 2&lt;/P&gt;&lt;P&gt;1 9 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0 0.89 0 3&lt;/P&gt;&lt;P&gt;7 6 0 0.89 0 3&lt;/P&gt;&lt;P&gt;7 7 0 0.89 0 3&lt;/P&gt;&lt;P&gt;7 8 1 0.89 0 1&lt;/P&gt;&lt;P&gt;7 9 . 0.89 0 1&lt;/P&gt;&lt;P&gt;7 10 . 0.89 0 1&lt;/P&gt;&lt;P&gt;8 0 0 1.1 1 0&lt;/P&gt;&lt;P&gt;8 1 0 1.1 1 1&lt;/P&gt;&lt;P&gt;8 2 0 1.1 1 1&lt;/P&gt;&lt;P&gt;8 3 . 1.1 1 2&lt;/P&gt;&lt;P&gt;8 4 . 1.1 1 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, I have time-invariant and time-varying covariates and my dataset is arranged in a longitudinal way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I code in SAS for the same table "have":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc phreg data = have;&lt;BR /&gt;class independent_v1(ref='0') independent_v2(ref='0');&lt;BR /&gt;id id;&lt;BR /&gt;model time1*event1(0) = independent_v1 independent_v2 / rl;&lt;BR /&gt;weight weight;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I code in STATA for the same table "have":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;stset time1 [pweight=weight], id(id) failure(event1=1)&lt;/P&gt;&lt;P&gt;char&amp;nbsp;&lt;SPAN&gt;independent_v1[omit] 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;char independent_v2[omit] 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;xi: stcox i.independent_v1 i.independent_v2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any clue ?&lt;/P&gt;</description>
    <pubDate>Fri, 19 Oct 2018 21:09:25 GMT</pubDate>
    <dc:creator>MFraga</dc:creator>
    <dc:date>2018-10-19T21:09:25Z</dc:date>
    <item>
      <title>Difference in STATA and SAS results for Cox regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-STATA-and-SAS-results-for-Cox-regression/m-p/506170#M26018</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to understand why my regressions give me different results when I run the models in SAS or STATA. I am a new SAS user and I am trying to do survival analysis for the first time with SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this point, I have to produce Cox regressions and as I do not know very much abour SAS, I compare the results in SAS with my results from STATA to make sure that I have done the good thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of my dataset would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id time1 event1 weight independent_v1 independent_v2;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 0 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 1 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 2 0 0.8 0 0&lt;/P&gt;&lt;P&gt;1 3 0 0.8 0 0&lt;/P&gt;&lt;P&gt;1 4 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 5 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 6 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 7 0 0.8 0 1&lt;/P&gt;&lt;P&gt;1 8 0 0.8 0 2&lt;/P&gt;&lt;P&gt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;7 5 0 0.89 0 3&lt;/P&gt;&lt;P&gt;7 6 0 0.89 0 3&lt;/P&gt;&lt;P&gt;7 7 0 0.89 0 3&lt;/P&gt;&lt;P&gt;7 8 1 0.89 0 1&lt;/P&gt;&lt;P&gt;7 9 . 0.89 0 1&lt;/P&gt;&lt;P&gt;7 10 . 0.89 0 1&lt;/P&gt;&lt;P&gt;8 0 0 1.1 1 0&lt;/P&gt;&lt;P&gt;8 1 0 1.1 1 1&lt;/P&gt;&lt;P&gt;8 2 0 1.1 1 1&lt;/P&gt;&lt;P&gt;8 3 . 1.1 1 2&lt;/P&gt;&lt;P&gt;8 4 . 1.1 1 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, I have time-invariant and time-varying covariates and my dataset is arranged in a longitudinal way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I code in SAS for the same table "have":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc phreg data = have;&lt;BR /&gt;class independent_v1(ref='0') independent_v2(ref='0');&lt;BR /&gt;id id;&lt;BR /&gt;model time1*event1(0) = independent_v1 independent_v2 / rl;&lt;BR /&gt;weight weight;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I code in STATA for the same table "have":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;stset time1 [pweight=weight], id(id) failure(event1=1)&lt;/P&gt;&lt;P&gt;char&amp;nbsp;&lt;SPAN&gt;independent_v1[omit] 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;char independent_v2[omit] 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;xi: stcox i.independent_v1 i.independent_v2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any clue ?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Oct 2018 21:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-STATA-and-SAS-results-for-Cox-regression/m-p/506170#M26018</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-10-19T21:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in STATA and SAS results for Cox regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-STATA-and-SAS-results-for-Cox-regression/m-p/506231#M26019</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236673"&gt;@MFraga&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've never used STATA, but for PROC PHREG you cannot use your dataset HAVE as the input dataset without further preparations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt; either&lt;/STRONG&gt; a dataset with &lt;EM&gt;one&lt;/EM&gt; observation per subject and a time variable indicating when the event of interest occurred or the subject was censored &lt;STRONG&gt;or&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;a dataset with (one or) multiple observations per subject each of which describes a &lt;EM&gt;time interval&lt;/EM&gt;. In this case&lt;EM&gt; two&lt;/EM&gt; time variables indicate the start and end point of the interval&amp;nbsp;&lt;STRONG&gt;(&lt;/STRONG&gt;t1, t2&lt;STRONG&gt;]&lt;/STRONG&gt;. This second option is referred to as &lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_phreg_details12.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_blank"&gt;Counting Process Style of Input&lt;/A&gt;&amp;nbsp;in the documentation.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;In the first case, time-dependent covariates can be defined using programming statements (similar to DATA step statements) in the PROC PHREG step. For your data&amp;nbsp;the second option is more suitable because the changes of &lt;FONT face="courier new,courier"&gt;independent_v2&lt;/FONT&gt;&amp;nbsp;don't follow a simple pattern. Please see &lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_phreg_examples07.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_blank"&gt;Example 87.7 Time-Dependent Repeated Measurements of a Covariate&lt;/A&gt;&amp;nbsp;in the documentation and create a modified input dataset from&amp;nbsp;dataset HAVE correspondingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: Using the second option&amp;nbsp;&lt;SPAN&gt;time-dependent covariates &lt;EM&gt;are&lt;/EM&gt; allowed as CLASS variables.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Oct 2018 14:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-STATA-and-SAS-results-for-Cox-regression/m-p/506231#M26019</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-21T14:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Difference in STATA and SAS results for Cox regression</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-STATA-and-SAS-results-for-Cox-regression/m-p/506589#M26030</link>
      <description>&lt;P&gt;I ran my regressions again and the results were not equal, but satisfactorily close. I think this difference may be due to the "weight" variable in the way it is used by SAS and STATA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, thanks again for the great text you sent me. It is really clear about how the dataset must be organized.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 19:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Difference-in-STATA-and-SAS-results-for-Cox-regression/m-p/506589#M26030</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-10-22T19:40:00Z</dc:date>
    </item>
  </channel>
</rss>

