<?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 Create a hazard graph with PROC PHREG including a random statement in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Create-a-hazard-graph-with-PROC-PHREG-including-a-random/m-p/836544#M41439</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a dataset that includes rows with&lt;/P&gt;&lt;P&gt;- people who viewed TV advertisements at a given time, and whether or not these people visited the website of the advertiser afterwards (+ the timestamp of this visit)&lt;/P&gt;&lt;P&gt;- a match for each of these people who did NOT see the TV advertisement at this same time, and whether or not these people visited the website of the advertiser afterwards&amp;nbsp;(+ the timestamp of this visit)&lt;/P&gt;&lt;P&gt;To give a simplified idea:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeenDS_2-1664810918452.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75824iD16A16DC7B87EA30/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeenDS_2-1664810918452.png" alt="LeenDS_2-1664810918452.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;On each row we also have a bunch of dummy variables for the week, weekend vs weekday, daypart (primetime etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use PROC PHREG to model the duration of the treatment effect (=seeing a TV ad) on online response (web visit). We included a random term for the advertisement, because the same advertisement is shown many times on different timestamps and to different people.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We would like to produce a hazard graph including the time-related control variables + including the random term. Is that possible?&lt;/P&gt;&lt;P&gt;Ideally, I'd get something similar to the below output that I generated with PROC LIFETEST, but including control variables and the random term (which is not possible with PROC LIFETEST).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeenDS_1-1664810545255.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75822i01054583D779420D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeenDS_1-1664810545255.png" alt="LeenDS_1-1664810545255.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC PHREG only produces a cumulative hazard graph and a survival graph. By using the COVS statement, I can control for the time-related variables. For now, I calculated the hazard rates by doing cumhaz - lag(cumhaz) directly in the output dataset. Not sure if this is allowed?&lt;/P&gt;&lt;P&gt;Also, I cannot produce any output results if I include the random statement (The PLOTS=, OUTPUT=, ... options are ignored for a frailty model analysis). Does anyone know of a method to go around this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advance for any input!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA covs;&lt;BR /&gt;FORMAT treatment best12. d_daytime_9_16 best12. d_earlyfringe_16_20 best12. d_primetime_20_23 best12. d_latefringe_23_5 best12.&lt;BR /&gt;d_weekend best12.&amp;nbsp;&lt;BR /&gt;d_week14 best12. d_week15 best12. d_week16 best12. d_week17 best12. d_week18 best12. d_week19 best12. d_week20 best12.&lt;BR /&gt;d_week21 best12. d_week22 best12. d_week23 best12. d_week24 best12. d_week25 best12. d_week26 best12.;&lt;BR /&gt;INPUT treatment d_daytime_9_16 d_earlyfringe_16_20 d_primetime_20_23 d_latefringe_23_5&lt;BR /&gt;d_weekend&amp;nbsp;&lt;BR /&gt;d_week14 d_week15 d_week16 d_week17 d_week18 d_week19 d_week20 d_week21 d_week22 d_week23 d_week24 d_week25 d_week26&lt;BR /&gt;;&lt;BR /&gt;DATALINES;&lt;BR /&gt;0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0&lt;BR /&gt;1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods graphics on;&lt;BR /&gt;PROC PHREG DATA=metrics_v4 PLOTS(overlay range=0,10080)=(survival cumhaz);&lt;BR /&gt;CLASS advertisement treatment(ref="0") visit(ref="0")&lt;BR /&gt;d_daytime_9_16(ref="0") d_earlyfringe_16_20(ref="0") d_primetime_20_23(ref="0") d_latefringe_23_5(ref="0")&lt;BR /&gt;d_weekend(ref="0")&amp;nbsp;&lt;BR /&gt;d_week14(ref="0") d_week15(ref="0") d_week16(ref="0") d_week17(ref="0") d_week18(ref="0") d_week19(ref="0")&amp;nbsp;d_week20(ref="0") d_week21(ref="0") d_week22(ref="0") d_week23(ref="0") d_week24(ref="0") d_week25(ref="0") d_week26(ref="0")&lt;BR /&gt;;&lt;BR /&gt;MODEL survivaltime*visit(0) = treatment&amp;nbsp;&lt;BR /&gt;d_daytime_9_16 d_earlyfringe_16_20 d_primetime_20_23 d_latefringe_23_5&lt;BR /&gt;d_weekend&amp;nbsp;&lt;BR /&gt;d_week14 d_week15 d_week16 d_week17 d_week18 d_week19 d_week20 d_week21 d_week22 d_week23 d_week24 d_week25 d_week26&lt;BR /&gt;;&lt;BR /&gt;BASELINE COVARIATES=covs OUT=base SURVIVAL=surv CUMHAZ=cumhaz / ROWID=treatment;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA test_haz;&lt;BR /&gt;SET base;&lt;BR /&gt;haz = cumhaz - lag(cumhaz);&lt;BR /&gt;if cumhaz=0 then haz = .;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Oct 2022 15:39:18 GMT</pubDate>
    <dc:creator>LeenDS</dc:creator>
    <dc:date>2022-10-03T15:39:18Z</dc:date>
    <item>
      <title>Create a hazard graph with PROC PHREG including a random statement</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Create-a-hazard-graph-with-PROC-PHREG-including-a-random/m-p/836544#M41439</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a dataset that includes rows with&lt;/P&gt;&lt;P&gt;- people who viewed TV advertisements at a given time, and whether or not these people visited the website of the advertiser afterwards (+ the timestamp of this visit)&lt;/P&gt;&lt;P&gt;- a match for each of these people who did NOT see the TV advertisement at this same time, and whether or not these people visited the website of the advertiser afterwards&amp;nbsp;(+ the timestamp of this visit)&lt;/P&gt;&lt;P&gt;To give a simplified idea:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeenDS_2-1664810918452.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75824iD16A16DC7B87EA30/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeenDS_2-1664810918452.png" alt="LeenDS_2-1664810918452.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;On each row we also have a bunch of dummy variables for the week, weekend vs weekday, daypart (primetime etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use PROC PHREG to model the duration of the treatment effect (=seeing a TV ad) on online response (web visit). We included a random term for the advertisement, because the same advertisement is shown many times on different timestamps and to different people.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We would like to produce a hazard graph including the time-related control variables + including the random term. Is that possible?&lt;/P&gt;&lt;P&gt;Ideally, I'd get something similar to the below output that I generated with PROC LIFETEST, but including control variables and the random term (which is not possible with PROC LIFETEST).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LeenDS_1-1664810545255.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75822i01054583D779420D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LeenDS_1-1664810545255.png" alt="LeenDS_1-1664810545255.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC PHREG only produces a cumulative hazard graph and a survival graph. By using the COVS statement, I can control for the time-related variables. For now, I calculated the hazard rates by doing cumhaz - lag(cumhaz) directly in the output dataset. Not sure if this is allowed?&lt;/P&gt;&lt;P&gt;Also, I cannot produce any output results if I include the random statement (The PLOTS=, OUTPUT=, ... options are ignored for a frailty model analysis). Does anyone know of a method to go around this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advance for any input!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA covs;&lt;BR /&gt;FORMAT treatment best12. d_daytime_9_16 best12. d_earlyfringe_16_20 best12. d_primetime_20_23 best12. d_latefringe_23_5 best12.&lt;BR /&gt;d_weekend best12.&amp;nbsp;&lt;BR /&gt;d_week14 best12. d_week15 best12. d_week16 best12. d_week17 best12. d_week18 best12. d_week19 best12. d_week20 best12.&lt;BR /&gt;d_week21 best12. d_week22 best12. d_week23 best12. d_week24 best12. d_week25 best12. d_week26 best12.;&lt;BR /&gt;INPUT treatment d_daytime_9_16 d_earlyfringe_16_20 d_primetime_20_23 d_latefringe_23_5&lt;BR /&gt;d_weekend&amp;nbsp;&lt;BR /&gt;d_week14 d_week15 d_week16 d_week17 d_week18 d_week19 d_week20 d_week21 d_week22 d_week23 d_week24 d_week25 d_week26&lt;BR /&gt;;&lt;BR /&gt;DATALINES;&lt;BR /&gt;0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0&lt;BR /&gt;1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods graphics on;&lt;BR /&gt;PROC PHREG DATA=metrics_v4 PLOTS(overlay range=0,10080)=(survival cumhaz);&lt;BR /&gt;CLASS advertisement treatment(ref="0") visit(ref="0")&lt;BR /&gt;d_daytime_9_16(ref="0") d_earlyfringe_16_20(ref="0") d_primetime_20_23(ref="0") d_latefringe_23_5(ref="0")&lt;BR /&gt;d_weekend(ref="0")&amp;nbsp;&lt;BR /&gt;d_week14(ref="0") d_week15(ref="0") d_week16(ref="0") d_week17(ref="0") d_week18(ref="0") d_week19(ref="0")&amp;nbsp;d_week20(ref="0") d_week21(ref="0") d_week22(ref="0") d_week23(ref="0") d_week24(ref="0") d_week25(ref="0") d_week26(ref="0")&lt;BR /&gt;;&lt;BR /&gt;MODEL survivaltime*visit(0) = treatment&amp;nbsp;&lt;BR /&gt;d_daytime_9_16 d_earlyfringe_16_20 d_primetime_20_23 d_latefringe_23_5&lt;BR /&gt;d_weekend&amp;nbsp;&lt;BR /&gt;d_week14 d_week15 d_week16 d_week17 d_week18 d_week19 d_week20 d_week21 d_week22 d_week23 d_week24 d_week25 d_week26&lt;BR /&gt;;&lt;BR /&gt;BASELINE COVARIATES=covs OUT=base SURVIVAL=surv CUMHAZ=cumhaz / ROWID=treatment;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA test_haz;&lt;BR /&gt;SET base;&lt;BR /&gt;haz = cumhaz - lag(cumhaz);&lt;BR /&gt;if cumhaz=0 then haz = .;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 15:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Create-a-hazard-graph-with-PROC-PHREG-including-a-random/m-p/836544#M41439</guid>
      <dc:creator>LeenDS</dc:creator>
      <dc:date>2022-10-03T15:39:18Z</dc:date>
    </item>
  </channel>
</rss>

