<?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: calculate time difference in one column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871597#M344330</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;11:21:00+4:00:00=15:21:00&amp;nbsp; all time of assessment below this row and happened before 15:21:00&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Where does the 4 hours come from?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What would happen if row 6 at time&amp;nbsp;14:20:00 had an NRS Score of 10? Would then the wanted output on row 3 be 10?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Apr 2023 14:28:49 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-04-24T14:28:49Z</dc:date>
    <item>
      <title>calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871588#M344326</link>
      <description>&lt;P&gt;Hi, Appreciate any help for this. how to get NRS score 8 for timepoint 1 and medication O with SAS?&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;subject&lt;/TD&gt;&lt;TD&gt;timepoint(hour)&lt;/TD&gt;&lt;TD&gt;time of assessment&lt;/TD&gt;&lt;TD&gt;NRS score&lt;/TD&gt;&lt;TD&gt;medication&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;want output(NRS score)&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101-0011&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;09:00:59&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;6&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101-0011&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;11:13:00&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;3&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101-0011&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;11:21:00&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;8&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;O&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;8&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;(11:21:00+4:00:00=15:21:00&amp;nbsp; all time of assessment below this row and happened before 15:21:00 are consider as timepoint 1 group. pick up the maximum NRS score 8 as output )&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101-0011&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;12:13:00&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;7&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101-0011&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;13:59:59&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;6&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;O&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101-0011&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;14:20:00&lt;/FONT&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;8&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101_0011&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;16:10:33&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;9&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871588#M344326</guid>
      <dc:creator>sophielr</dc:creator>
      <dc:date>2023-04-24T14:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871594#M344328</link>
      <description>&lt;P&gt;Could you explain the logic behind what you want to achieve?&lt;/P&gt;
&lt;P&gt;Why record for 11:21:00 is more "special" than the one form&amp;nbsp;&lt;SPAN&gt;13:59:59 (which also have "O")?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871594#M344328</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-04-24T14:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871597#M344330</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;11:21:00+4:00:00=15:21:00&amp;nbsp; all time of assessment below this row and happened before 15:21:00&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Where does the 4 hours come from?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What would happen if row 6 at time&amp;nbsp;14:20:00 had an NRS Score of 10? Would then the wanted output on row 3 be 10?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871597#M344330</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-24T14:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871598#M344331</link>
      <description>&lt;P&gt;Hi&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;, the data I got from my boss. I picked up parts of the raw data. the second "O" is for another time point.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:29:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871598#M344331</guid>
      <dc:creator>sophielr</dc:creator>
      <dc:date>2023-04-24T14:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871600#M344333</link>
      <description>&lt;P&gt;Sorry for auto-quoting but: "&lt;SPAN&gt;Could you explain the logic behind what you want to achieve?&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;B.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871600#M344333</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-04-24T14:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871604#M344336</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;4 hours is the criteria according to this trial document. the wanted score should be 10&lt;SPAN&gt;&amp;nbsp;if row 6 at time&amp;nbsp;14:20:00 had an NRS Score of 10.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871604#M344336</guid>
      <dc:creator>sophielr</dc:creator>
      <dc:date>2023-04-24T14:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871608#M344339</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope you understand my explanation. for timepoint 1 and medication A: assessment time 11:21:00+4:00:00=15:21:00,&amp;nbsp; all times of assessment below this row and happened before 15:21:00 are considered as timepoint 1 group. pick up the maximum NRS score 8 in this group as output&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:41:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871608#M344339</guid>
      <dc:creator>sophielr</dc:creator>
      <dc:date>2023-04-24T14:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871612#M344343</link>
      <description>&lt;P&gt;I was going to ask: then why don't we created wanted output for row 6, which also has medication O? I think this is what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;&amp;nbsp;wants to know as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I am not going to ask that. We have reached a point, just like in your &lt;A href="https://communities.sas.com/t5/SAS-Programming/find-max-score-in-a-range/td-p/870811" target="_self"&gt;last thread&lt;/A&gt;, where we have to ask 20 questions to get a clear understanding of the problem. This is not a good way to get the help you need.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/441980"&gt;@sophielr&lt;/a&gt;&amp;nbsp;— would you please write a complete and clear explanation of the entire problem? Please do that rather than us asking question and follow-up question and another follow-up question. Emphasis on COMPLETE. Emphasis on CLEAR.&amp;nbsp;&amp;nbsp;Emphasis on COMPLETE.&amp;nbsp;Emphasis on COMPLETE.&amp;nbsp;Emphasis on COMPLETE.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871612#M344343</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-24T14:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871615#M344344</link>
      <description>&lt;P&gt;You wan to "see into the future" for 4 hours, what about "the past"? is it "select all before" or maybe there is some limitation ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871615#M344344</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-04-24T14:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871619#M344346</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;yes, I need to calculate the row 6 score also. I want to make my question easy so I will do the next part if I know how to calculate the first one.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871619#M344346</guid>
      <dc:creator>sophielr</dc:creator>
      <dc:date>2023-04-24T14:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871621#M344348</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not need to consider "the past time" right now. I only want to know how to find the rows in the calculated range( recorded time +4hours) and then find maximum number in this range.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 15:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871621#M344348</guid>
      <dc:creator>sophielr</dc:creator>
      <dc:date>2023-04-24T15:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871622#M344349</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/441980"&gt;@sophielr&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;yes, I need to calculate the row 6 score also. I want to make my question easy so I will do the next part if I know how to calculate the first one.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't want answers to the specific questions that have been asked. I have already said that I want a COMPLETE and CLEAR explanation of the problem so we don't have to keep asking more questions, and so we don't have to keep scrolling up and down to understand your answers and how they relate to the data.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 15:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871622#M344349</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-24T15:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871624#M344351</link>
      <description>&lt;P&gt;I did my best guess:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards missover;
input subject : $ 20. timepoint time_of_assessment time8. NRS_score medication $;
format time_of_assessment time.;
cards;
101-0011 0 09:00:59 6    
101-0011 1 11:13:00 3    
101-0011 1 11:21:00 8 O 
101-0011 2 12:13:00 7    
101-0011 4 13:59:59 6 O  
101-0011 4 14:20:00 8    
101-0011 6 16:10:33 9  
101-0012 0 09:00:59 6    
101-0012 1 11:13:00 3    
101-0012 1 11:21:00 8 O 
101-0012 2 12:13:00 7    
101-0012 4 17:59:59 6 O  
101-0012 4 18:20:00 1    
101-0012 6 19:10:33 3 
;
run;
proc print;
run;

data have1;
  set have;
  where medication="O";
    
  rangelow = 0;
  rangeup  = time_of_assessment + 4*60*60;

  keep subject time_of_assessment medication rangelow rangeup;
run;
proc print;
run;

proc sql;
  create table have2 as
  select a.subject, a.time_of_assessment, max(b.NRS_score) as max_score
  from have1 as a, have as b
  where a.subject = b.subject 
    and b.time_of_assessment between a.rangelow and a.rangeup
  group by a.subject, a.time_of_assessment
  order by a.subject, a.time_of_assessment
  ;
quit;
proc print;
run;

data want;
  merge have have2;
  by subject time_of_assessment;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 15:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871624#M344351</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-04-24T15:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: calculate time difference in one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871628#M344355</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;, you give me a big help.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 15:17:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-time-difference-in-one-column/m-p/871628#M344355</guid>
      <dc:creator>sophielr</dc:creator>
      <dc:date>2023-04-24T15:17:33Z</dc:date>
    </item>
  </channel>
</rss>

