<?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: More than one time-dependent variable in a time-dependent Cox regression in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/930570#M366126</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184847"&gt;@TomHsiung&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would think of the two or more&amp;nbsp;&lt;SPAN&gt;time-dependent explanatory variables as &lt;EM&gt;one vector-valued&lt;/EM&gt; variable and then use either of the two methods from the paper (or even both, for validation purposes) to build the model.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;With&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_details12.htm" target="_blank" rel="noopener"&gt;counting process style of input&lt;/A&gt;: Create an input dataset with one observation per individual &lt;EM&gt;and&lt;/EM&gt;&amp;nbsp;time interval (start, stop] where the &lt;EM&gt;combination&lt;/EM&gt; of all time-dependent explanatory variables (i.e., the "vector") is constant, until one or more of the components of the vector change or a change of status (event or censoring) occurs.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Using &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_syntax19.htm" target="_blank" rel="noopener"&gt;programming statements&lt;/A&gt;: Assign each component of the vector its time-dependent value (using one or more arrays or IF-THEN/ELSE statements or whatever is appropriate).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Which of the two methods is more convenient, depends on the structure and other characteristics of your data.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 02 Jun 2024 18:43:39 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2024-06-02T18:43:39Z</dc:date>
    <item>
      <title>More than one time-dependent variable in a time-dependent Cox regression in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/930074#M365937</link>
      <description>&lt;P&gt;Hello, everyone&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not uncommon that we have to control more than one time-dependent variable in a Cox regression model. A SAS support PDF document teaches two methods to code for a time-dependent Cox model, but, with only one time-dependent variable adjusted (link: &lt;A href="https://support.sas.com/resources/papers/proceedings12/168-2012.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings12/168-2012.pdf&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first method involves constructing a special data set for the time-dependent variable data and the example is for only one time-dependent variable. It does not teach what to do if there is more than one such variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second method is more advanced, termed "programming statment method". It has only one record for each individual, compared with the first method which has multiple records for each individual.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonder how to code for the Cox model if there are 2 or more time-dependent variables, by both method 1 and 2. Thank you very much.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 07:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/930074#M365937</guid>
      <dc:creator>TomHsiung</dc:creator>
      <dc:date>2024-05-29T07:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: More than one time-dependent variable in a time-dependent Cox regression in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/930570#M366126</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184847"&gt;@TomHsiung&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would think of the two or more&amp;nbsp;&lt;SPAN&gt;time-dependent explanatory variables as &lt;EM&gt;one vector-valued&lt;/EM&gt; variable and then use either of the two methods from the paper (or even both, for validation purposes) to build the model.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;With&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_details12.htm" target="_blank" rel="noopener"&gt;counting process style of input&lt;/A&gt;: Create an input dataset with one observation per individual &lt;EM&gt;and&lt;/EM&gt;&amp;nbsp;time interval (start, stop] where the &lt;EM&gt;combination&lt;/EM&gt; of all time-dependent explanatory variables (i.e., the "vector") is constant, until one or more of the components of the vector change or a change of status (event or censoring) occurs.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Using &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_syntax19.htm" target="_blank" rel="noopener"&gt;programming statements&lt;/A&gt;: Assign each component of the vector its time-dependent value (using one or more arrays or IF-THEN/ELSE statements or whatever is appropriate).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Which of the two methods is more convenient, depends on the structure and other characteristics of your data.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jun 2024 18:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/930570#M366126</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-06-02T18:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: More than one time-dependent variable in a time-dependent Cox regression in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/930802#M366206</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your suggestion. Hmmm, it's a great idea to deal with multiple time-dependent variables. Please let me reproduce your idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, via the counting process method. Say, we have two time-varying variables named A and B, and there are other fixed variables which is represented in union by U. If there is an individual who was followed for 14 days, for whom the A changed on day 7 from 0 to 1. In addition, the B changed on day 4 from 1 to 0. According to my understanding of your idea, there should be three rows for this individual in the overall table and they are:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;row one: A=0, B=1, start=0, stop=4&lt;/P&gt;
&lt;P&gt;row two: A=0, B=0, start=4, stop=7&lt;/P&gt;
&lt;P&gt;row three A=1, B=0, start=7, stop=14&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, every change in the time-varying variable produces an extra row for the individual, given that the time-varying variables do not change on the same day (i.e., tie).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have not yet thought about the programming method and if I have ideas about it I would update this post. Again, thank you for your feedback.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 13:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/930802#M366206</guid>
      <dc:creator>TomHsiung</dc:creator>
      <dc:date>2024-06-04T13:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: More than one time-dependent variable in a time-dependent Cox regression in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/930839#M366218</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184847"&gt;@TomHsiung&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your suggestion. (...)&amp;nbsp;&lt;SPAN&gt;If there is an individual who was followed for 14 days, for whom the A changed on day 7 from 0 to 1. In addition, the B changed on day 4 from 1 to 0. According to my understanding of your idea, there should be three rows for this individual in the overall table and they are:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;row one: A=0, B=1, start=0, stop=4&lt;/P&gt;
&lt;P&gt;row two: A=0, B=0, start=4, stop=7&lt;/P&gt;
&lt;P&gt;row three A=1, B=0, start=7, stop=14&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You're welcome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a situation with discrete (integer) times &lt;EM&gt;t&lt;SUB&gt;1&lt;/SUB&gt;&lt;/EM&gt;, &lt;EM&gt;t&lt;SUB&gt;2&lt;/SUB&gt;&lt;/EM&gt;, ..., as in your example, one has to make sure that the time-varying variables at time &lt;EM&gt;t&lt;SUB&gt;i&lt;/SUB&gt;&lt;/EM&gt; have the values that are relevant for the case that &lt;EM&gt;t&lt;SUB&gt;i&lt;/SUB&gt;&lt;/EM&gt; is the event time of the individual they describe. This is illustrated in&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_phreg_examples07.htm" target="_blank" rel="noopener"&gt;Example 92.7 Time-Dependent Repeated Measurements of a Covariate&lt;/A&gt; of the PROC PHREG documentation: A value measured at time&amp;nbsp;&lt;EM&gt;t&lt;SUB&gt;i&lt;/SUB&gt;&lt;/EM&gt; is assumed to be valid in the entire semiclosed interval (&lt;EM&gt;t&lt;SUB&gt;i-1&lt;/SUB&gt;&lt;/EM&gt;, &lt;EM&gt;t&lt;SUB&gt;i&lt;/SUB&gt;&lt;/EM&gt;] where&amp;nbsp;&lt;EM&gt;t&lt;SUB&gt;i-1&lt;/SUB&gt;&lt;/EM&gt; is the time of the previous measurement (or zero if &lt;EM&gt;i&lt;/EM&gt;=1). Time&amp;nbsp;&lt;EM&gt;t&lt;SUB&gt;i-1&lt;/SUB&gt;&lt;/EM&gt; must not be equal to&amp;nbsp;&lt;EM&gt;t&lt;SUB&gt;i&lt;/SUB&gt;&lt;/EM&gt; in this situation. Otherwise, PROC PHREG would discard the observation and issue a note about this in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, if you know that "&lt;SPAN&gt;B changed &lt;EM&gt;&lt;STRONG&gt;on&lt;/STRONG&gt;&lt;/EM&gt; day 4 from 1 to 0," (&lt;EM&gt;and not&lt;/EM&gt;: "it may have changed earlier, but the first measurement detecting the change happened to be that on day 4") I think it would be more appropriate to have a time interval with stop time &lt;EM&gt;3&lt;/EM&gt; and B=1, followed by an interval with start time 3 and B=0. Similarly, knowing that "A changed &lt;STRONG&gt;on&lt;/STRONG&gt; day 7 from 0 to 1," the latter interval would rather have stop time &lt;EM&gt;6&lt;/EM&gt;&amp;nbsp;and A=0.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;start    stop    A    B

  0        3     0    1
  3        6     0    0
  6       14     1    0&lt;/PRE&gt;
&lt;P&gt;If the event or censoring time of that individual was day 7, the third observation would have stop=7 (and the corresponding value of the variable indicating event or censoring, not shown above). Thus, the model would take the potential impact of A=1 on the occurrence probability of the event into account since start=6&amp;lt;7=stop.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 16:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/930839#M366218</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-06-04T16:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: More than one time-dependent variable in a time-dependent Cox regression in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/932129#M366699</link>
      <description>&lt;P&gt;Thanks for the notice,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Great! And I have one more question. If the two time-varying variables change on the same day (tie), how do we count them? Only two rows with a same start and stop time? Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 13:38:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/932129#M366699</guid>
      <dc:creator>TomHsiung</dc:creator>
      <dc:date>2024-06-13T13:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: More than one time-dependent variable in a time-dependent Cox regression in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/932136#M366701</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184847"&gt;@TomHsiung&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If the two time-varying variables change on the same day (tie), how do we count them? Only two rows with a same start and stop time?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The general pattern is always the same: Each row represents a semiclosed time interval (start, stop] in which the time-varying variables are constant. If in the previous example not only&amp;nbsp;&lt;SPAN&gt;B changed&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;on&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;day 4 from 1 to 0, but also A from 0 to 1 (and remained constant thereafter), we would specify:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;start    stop    A    B

  0        3     0    1
  3       14     1    0&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;So, up to and including day 3 the "vector" (A, B)=(0, 1), whereas after day 3, i.e., on days 4, 5, ..., 14, (A, B)=(1, 0).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 14:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/932136#M366701</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-06-13T14:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: More than one time-dependent variable in a time-dependent Cox regression in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/933404#M367091</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;Thanks for your further explanation. I guess if we have more than 3 time-varying variables, this approach would be very laborious. I addition, the PROC TRANSPOSE might experience difficulty when transferring a wide dataset to a narrow dataset, given there is more than one time-varying variables (e.g., A_wk1, A_wk2, ... A_wkm, and B_wk1, B_wk2, ... B_wkn).&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2024 09:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/933404#M367091</guid>
      <dc:creator>TomHsiung</dc:creator>
      <dc:date>2024-06-22T09:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: More than one time-dependent variable in a time-dependent Cox regression in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/934164#M367367</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184847"&gt;@TomHsiung&lt;/a&gt;: Sorry for the delayed reply, I was out of the office for a week.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184847"&gt;@TomHsiung&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I guess if we have more than 3 time-varying variables, this approach would be very laborious.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't think I've ever had that many time-varying variables in a Cox model. But since the counting process style of input follows a&amp;nbsp;&lt;SPAN&gt;general pattern -- a change in one of the time-varying variables calls for a new observation in the input dataset -- it should be possible to use DATA step programming logic to create all those observations. See the recent post&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Counting-process-time-dependent-cox-model/m-p/927579/highlight/true#M365014" target="_blank" rel="noopener"&gt;Re: Counting process time dependent cox model&lt;/A&gt; for an example (for &lt;EM&gt;discrete&lt;/EM&gt; times).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/184847"&gt;@TomHsiung&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I addition, the PROC TRANSPOSE might experience difficulty when transferring a wide dataset to a narrow dataset, given there is more than one time-varying variables (e.g., A_wk1, A_wk2, ... A_wkm, and B_wk1, B_wk2, ... B_wkn).&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Data transformations from wide to long (and vice versa) have been discussed many times in the SAS Support Communities: please see the search results&amp;nbsp;&lt;A href="https://communities.sas.com/t5/forums/searchpage/tab/message?q=%22wide%20to%20long%22&amp;amp;noSynonym=false&amp;amp;sort_by=score&amp;amp;collapse_discussion=true" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/forums/searchpage/tab/message?q=%22wide%20to%20long%22&amp;amp;noSynonym=false&amp;amp;sort_by=score&amp;amp;collapse_discussion=true&lt;/A&gt;&amp;nbsp;or open a new thread describing your specific problem.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jun 2024 13:15:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-than-one-time-dependent-variable-in-a-time-dependent-Cox/m-p/934164#M367367</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-06-29T13:15:38Z</dc:date>
    </item>
  </channel>
</rss>

