<?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: Summarize overlapping medications in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304138#M64705</link>
    <description>&lt;P&gt;Patient? Your example data does not cleary identify "Patient". If the ID is Patient then the example data is incomplete for the summary result shown.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Oct 2016 15:48:40 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-10-12T15:48:40Z</dc:date>
    <item>
      <title>Summarize overlapping medications</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304122#M64699</link>
      <description>&lt;P&gt;Hi All, I have the following dataset&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id rx
1  a
1  b
1  d
2  a 
2  b
3  a
3 c
4  b&lt;BR /&gt;5  a&lt;BR /&gt;5  d&lt;BR /&gt;6  a&lt;BR /&gt;6  c&lt;BR /&gt;7  a&lt;BR /&gt;7  b&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am trying&amp;nbsp;to summarize these combination as aggregate, here is the output I want &amp;nbsp;&lt;/P&gt;&lt;P&gt;a-b-d 1&lt;/P&gt;&lt;P&gt;a-b&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;a-c &amp;nbsp;2&lt;/P&gt;&lt;P&gt;b &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;a-d&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 15:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304122#M64699</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-10-12T15:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize overlapping medications</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304125#M64701</link>
      <description>&lt;P&gt;How do you get "a-c 2" and "a-d 1" from that data? You seem to be missing a detail or two on what you are counting and how to count it. At least I think those are supposed to be counts.&lt;/P&gt;
&lt;P&gt;How many values may be in RX for a single row?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 15:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304125#M64701</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-12T15:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize overlapping medications</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304127#M64702</link>
      <description>&lt;P&gt;For some reason, when I edit the dataset i get it correct but it is not when posted. Here are the correct entries:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id rx
1  a
1  b
1  d
2  a 
2  b
3  a
3 c
4  b&lt;BR /&gt;5  a&lt;BR /&gt;5  d&lt;BR /&gt;6  a&lt;BR /&gt;6  c&lt;BR /&gt;7  a&lt;BR /&gt;7  b&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;for patient 4 (b), patient 5 (a, d), patient 6 (a, c) and patients 7 (a,b) so you get 2 for a-c because patient 3 had a-c and patient 6 has a-c too. You are right for a-d, the triple combination can be counted under different category so for patient 1, it could be a-b, a-d and b-d and a-b-d but for smipliciy,&amp;nbsp;I would count this only once as a-b-c so patient can be counted only one time in the aggregate measure.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 15:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304127#M64702</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-10-12T15:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize overlapping medications</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304138#M64705</link>
      <description>&lt;P&gt;Patient? Your example data does not cleary identify "Patient". If the ID is Patient then the example data is incomplete for the summary result shown.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 15:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304138#M64705</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-12T15:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize overlapping medications</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304139#M64706</link>
      <description>&lt;P&gt;Apologize if I am not clear, I will simplify my example.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;patient_id rx
1              a
1              b
1              c
2              a
2              b
3              a
3              b&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;The output would be&lt;/P&gt;&lt;P&gt;a-b-c &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;a-b&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 15:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304139#M64706</guid>
      <dc:creator>lillymaginta</dc:creator>
      <dc:date>2016-10-12T15:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Summarize overlapping medications</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304156#M64714</link>
      <description>&lt;P&gt;For data in that form this works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input patient_id rx $;
datalines;
1              a
1              b
1              c
2              a
2              b
3              a
3              b
;
run;

proc sort data=have; 
  by patient_id rx;
run;

proc transpose data=have
   out=trans;
by patient_id;
var rx;
run;

data want;
   set trans;
   array c col: ;
   length rx_list $ 200;
   rx_list= catx('-',of c(*));
   drop col: _name_ ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But this will only work if there is one RX per record and the RX doesn't repeat, unless you want a-a-b. If you don't want the repeats then add NODUPKEY to the Proc sort.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The sort also is used to keep from getting a-b and b-a as different results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am concerned about the patient 4 in your original post though. If you have multiple RX in a single record then you should consider making sure the structure is one RX per patient record which will involve some additional code.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2016 17:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summarize-overlapping-medications/m-p/304156#M64714</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-12T17:37:03Z</dc:date>
    </item>
  </channel>
</rss>

