<?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: SAS programming statement in proc phreg in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680232#M205535</link>
    <description>Ah yes, I agree the above do loop creates 1 var_pm25. But, it's my understanding the do loop as a data step works differently from a do loop in a proc phreg. I'm trying to replicate the do loop in proc phreg in a data step -- suggestions? thanks!</description>
    <pubDate>Sat, 29 Aug 2020 17:55:12 GMT</pubDate>
    <dc:creator>pamplemouse22</dc:creator>
    <dc:date>2020-08-29T17:55:12Z</dc:date>
    <item>
      <title>SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680126#M205472</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running a cox model with time-varying exposure. Exact age is the time scale and the exposure varies by calendar year. I have this code that creates the following output:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc  phreg  data  = dat ;
	model age* outcome(0)  =  var_pm25  edu sex center/  rl entry=age0;
	array pm25 {15} 	pm25_1999 - pm25_2013  ;
	do  i  =  1  to  15;
	if (age1999+i-1)&amp;lt;age&amp;lt;=(age1999+i) then var_pm25=  pm25[i];
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pamplemouse22_1-1598650568481.png" style="width: 305px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48771iE67425994DE379BC/image-dimensions/305x86?v=v2" width="305" height="86" role="button" title="pamplemouse22_1-1598650568481.png" alt="pamplemouse22_1-1598650568481.png" /&gt;&lt;/span&gt;&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="pamplemouse22_0-1598650551345.png" style="width: 452px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48770iFC3B18316584C73E/image-dimensions/452x86?v=v2" width="452" height="86" role="button" title="pamplemouse22_0-1598650551345.png" alt="pamplemouse22_0-1598650551345.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I recreate the above results, without the programming statement? I tried to include the array in a data step before the proc, and the array pulls the exposure I am interested in. but the total sample, and number of events with missing, and hazard ratio are (very) different. I think it has something to do with when the exposure is pulled. code/results below.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test; 
	set dat;
	array pm25 {15} 	pm25_1999 - pm25_2013  ;
	array pm25_new {15} 	_1999 - _2013  ;
	do  i  =  1  to  15;
	if (age1999+i-1)&amp;lt;age&amp;lt;=(age1999+i) then pm25_new[i]=  pm25[i]/5;
	end;
run;  

data test2; 
	set test; 
	pm25_new=sum (of _1999-_2013); 
run;

proc  phreg  data  = test2 ;
	model age* outcome(0)  =  pm25_new  edu sexe cod_cen /  rl entry=age0;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pamplemouse22_2-1598650906036.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48772i436DB786AA7EB226/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pamplemouse22_2-1598650906036.png" alt="pamplemouse22_2-1598650906036.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pamplemouse22_3-1598650927783.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/48773i8EFE9FAD6B5D2590/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pamplemouse22_3-1598650927783.png" alt="pamplemouse22_3-1598650927783.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 21:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680126#M205472</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2020-08-28T21:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680194#M205509</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/112197"&gt;@pamplemouse22&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think your current approach (using dataset &lt;FONT face="courier new,courier"&gt;test2&lt;/FONT&gt;) cannot work because variable&amp;nbsp;&lt;FONT face="courier new,courier"&gt;pm25_new&lt;/FONT&gt; is (necessarily) constant, while it ought to be time-dependent (like &lt;FONT face="courier new,courier"&gt;var_pm25&lt;/FONT&gt;). It should be possible, however, to omit the programming statements in the PROC PHREG step if you create an input dataset with&amp;nbsp;&lt;SPAN&gt;a different structure (and use the slightly different syntax for such datasets in the MODEL statement): see&amp;nbsp;&lt;/SPAN&gt;&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" rel="noopener nofollow noopener noreferrer"&gt;Counting Process Style of Input&lt;/A&gt;&lt;SPAN&gt;. There you have multiple observations per subject, corresponding to disjoint time intervals, which enables you to define different values of a time-dependent covariate in different time intervals.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 12:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680194#M205509</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-08-29T12:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680208#M205520</link>
      <description>Hi, Thanks for your reply. I think you are right and I am trying to change my dataset to the counting style, but am still unable to match my results. What is confusing to me is that my time scale is age, but my exposure is determined by calendar time (calendar year). I can't find a good example of this to follow.&lt;BR /&gt;Currently, my dataset has 1 row per person-calendar year, and there is a start age, and stop age, and pm25 value that varies for each row. This still doesn't produce the numbers I want. Suggestions?</description>
      <pubDate>Sat, 29 Aug 2020 15:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680208#M205520</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2020-08-29T15:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680209#M205521</link>
      <description>&lt;P&gt;If the approach using&amp;nbsp;&lt;FONT face="courier new,courier"&gt;var_pm25&lt;/FONT&gt; works, why do you want to eliminate the programming statements from the PROC PHREG step?&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 15:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680209#M205521</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-08-29T15:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680210#M205522</link>
      <description>&lt;P&gt;Why did you change the logic to divide by 5?&amp;nbsp; And then SUM?&lt;/P&gt;
&lt;P&gt;What happens if you just use the same logic?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test; 
	set dat;
	array pm25 {15} 	pm25_1999 - pm25_2013  ;
	do  i  =  1  to  15;
	if (age1999+i-1)&amp;lt;age&amp;lt;=(age1999+i) then var_pm25 =  pm25[i];
	end;
run;  
proc  phreg  data  = test;
	model age* outcome(0)  =  var_pm25  edu sex center/  rl entry=age0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Aug 2020 15:26:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680210#M205522</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-08-29T15:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680218#M205527</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I divided by 5 since the original array also divides by 5 (this is just to change the unit increase for the final HR)&lt;BR /&gt;&lt;BR /&gt;The logic you presented is a little different since the final var_pm25 would be assigned pm25[15], rather than updating for each i . So, I did it as 2 steps where a new value is created for each i, and then i took the sum to get the value i'm interested in (each row only meets the if-logic once, this can be any i 1 to 15).&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 29 Aug 2020 15:58:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680218#M205527</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2020-08-29T15:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680219#M205528</link>
      <description>&lt;P&gt;Just to see if I understand how it works, properly. I guess I don't since I am not getting numbers to match! I also have to make some small changes, and need to understand this well so I feel confident in my changes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 15:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680219#M205528</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2020-08-29T15:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680221#M205530</link>
      <description>&lt;P&gt;I don't think you understand what the DO loop was doing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array pm25 {15} 	pm25_1999 - pm25_2013  ;
do  i  =  1  to  15;
  if (age1999+i-1)&amp;lt;age&amp;lt;=(age1999+i) then var_pm25 =  pm25[i];
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If was NOT generating 15 values of VAR_PM25. It was just finding which value to use based on the value of AGE compared to the value of AGE1999.&amp;nbsp; &amp;nbsp;So if the subject was 50 years old in 1999 and in this records they are now 51 it will use the value from the PM_2000 variable.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 16:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680221#M205530</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-08-29T16:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680222#M205531</link>
      <description>&lt;P&gt;If in doubt, I would probably do a simulation, i.e., create artificial data based on a (Cox-PH) model with known coefficients. I think a simplified model with the time-dependent covariate as the only predictor might be sufficient for this purpose. Chapter 12 of&amp;nbsp;&lt;A href="https://www.sas.com/store/de_de/books/categories/usage-and-reference/simulating-data-with-sas-/prodBK_65378_en.html" target="_blank" rel="noopener"&gt;Simulating Data with SAS®&lt;/A&gt; should contain instructions for that, but I don't have this book yet.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 16:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680222#M205531</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-08-29T16:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680231#M205534</link>
      <description>That is a great idea, I will try that! Thanks!</description>
      <pubDate>Sat, 29 Aug 2020 17:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680231#M205534</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2020-08-29T17:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680232#M205535</link>
      <description>Ah yes, I agree the above do loop creates 1 var_pm25. But, it's my understanding the do loop as a data step works differently from a do loop in a proc phreg. I'm trying to replicate the do loop in proc phreg in a data step -- suggestions? thanks!</description>
      <pubDate>Sat, 29 Aug 2020 17:55:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680232#M205535</guid>
      <dc:creator>pamplemouse22</dc:creator>
      <dc:date>2020-08-29T17:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS programming statement in proc phreg</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680234#M205537</link>
      <description>&lt;P&gt;Why would the logic of a do loop be different?&amp;nbsp; The only difference I know is that in PHREG the ARRAY statement requires the&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;{15}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;after the array name.&amp;nbsp; In a data step SAS is smart enough the know that pm25_1999 - pm25_2013 is 15 variables without adding that extra bit of code to the ARRAY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try the code i posted? Did you get the matching results?&lt;/P&gt;</description>
      <pubDate>Sat, 29 Aug 2020 18:06:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-programming-statement-in-proc-phreg/m-p/680234#M205537</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-08-29T18:06:04Z</dc:date>
    </item>
  </channel>
</rss>

