<?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: Summing variables across continuous rows of data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170566#M32751</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Worked perfectly, I can't thank you enough!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Oct 2014 22:40:48 GMT</pubDate>
    <dc:creator>Lefty</dc:creator>
    <dc:date>2014-10-02T22:40:48Z</dc:date>
    <item>
      <title>Summing variables across continuous rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170561#M32746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dataset like this:&lt;/P&gt;&lt;TABLE align="left" border="1" cellpadding="0" cellspacing="0" style="border: none; margin-left: 6.75pt; margin-right: 6.75pt;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;PatientID&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;DayDrugTaken&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR clear="all" /&gt; &lt;/P&gt;&lt;P&gt;I would like to know how many &lt;EM&gt;continuous&lt;/EM&gt; days in a row each patient took a drug. I used the following code&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; new; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; old;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;retain&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; firstday;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; PatientId;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; first.PatientId&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt; then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; firstday=&lt;/SPAN&gt; DayDrugTaken&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; last.PatientId&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt; then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; lastday=&lt;/SPAN&gt; DayDrugTaken&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;duration=(lastday-firstday)+&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; which created a table like this:&lt;/P&gt;&lt;TABLE align="left" border="1" cellpadding="0" cellspacing="0" style="border: none; margin-left: 6.75pt; margin-right: 6.75pt;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;PatientID&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;DayDrugTaken&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;FirstDay&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;LastDay&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Duration&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;.&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;.&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="91"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For patient 1, I have what I want in the “Duration” variable, 3 days. But for patient 2, I would like to have the Duration=2 because he only took the drug on days 3 and 4 continuously. Does anyone have any advice about how to calculate this in SAS?&lt;/P&gt;&lt;P&gt;Thank you so much in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 20:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170561#M32746</guid>
      <dc:creator>Lefty</dc:creator>
      <dc:date>2014-10-02T20:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: Summing variables across continuous rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170562#M32747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DIF() function is useful here&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 20:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170562#M32747</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2014-10-02T20:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Summing variables across continuous rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170563#M32748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you want for output if daydrugtake has values like: 1, 3,4, 6,7,8, 10,11&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 20:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170563#M32748</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-10-02T20:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Summing variables across continuous rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170564#M32749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In that case, I would like the duration=3 because the patient took drugs continuously for 3 days (6, 7, and &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 20:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170564#M32749</guid>
      <dc:creator>Lefty</dc:creator>
      <dc:date>2014-10-02T20:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: Summing variables across continuous rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170565#M32750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by PatientID DayDrugTaken notsorted;&lt;BR /&gt;dif=DayDrugTaken-lag(DayDrugTaken);&lt;BR /&gt;if first.PatientID or dif&amp;gt;1 then grp+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table final as&lt;BR /&gt;select PatientID, max(day) as continuous_days from (&lt;BR /&gt;select PatientID,grp,count(DayDrugTaken) as day&lt;BR /&gt;from want&lt;BR /&gt;group by PatientID,grp)&lt;BR /&gt;group by PatientID;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 22:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170565#M32750</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-10-02T22:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Summing variables across continuous rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170566#M32751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Worked perfectly, I can't thank you enough!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Oct 2014 22:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170566#M32751</guid>
      <dc:creator>Lefty</dc:creator>
      <dc:date>2014-10-02T22:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Summing variables across continuous rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170567#M32752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Seems to me there is an one-step solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt;set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt;by PatientID DayDrugTaken ;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;retain max_ct;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;ct+(dif(&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt;DayDrugTaken&lt;/SPAN&gt;)=1);&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt;if first.PatientID or &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;dif(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt;DayDrugTaken&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt;&amp;gt;1 then ct&lt;/SPAN&gt;=1;&lt;/P&gt;&lt;P&gt;max_ct=max(max_ct,ct);&lt;/P&gt;&lt;P&gt;if last.patientid then do; output;max_ct=1;end;&lt;/P&gt;&lt;P&gt;drop ct;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333330154419px; background-color: #ffffff;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 00:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170567#M32752</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-10-03T00:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Summing variables across continuous rows of data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170568#M32753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The approach can be reduced because the output is at ID level- then the DOW loop is effective&lt;/P&gt;&lt;P&gt;DATA persistency ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; KEEP&amp;nbsp; patientID persistence ;&lt;/P&gt;&lt;P&gt;DO pd= 1 BY 1 UNTIL( last.patientID ) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET old ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY patientID ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; difd = DIF( dayDrugTaken) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF&amp;nbsp; pd EQ 1 OR difd NE 1 THEN ct= 1 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE ct=ct+1 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; persistence = MAX( persistence, ct );&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;RUN ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 12:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-variables-across-continuous-rows-of-data/m-p/170568#M32753</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2014-10-03T12:15:21Z</dc:date>
    </item>
  </channel>
</rss>

