<?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 Counting drug use overlap along with the type of combination in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Counting-drug-use-overlap-along-with-the-type-of-combination/m-p/459538#M14233</link>
    <description>&lt;P&gt;I have a dataset that looks like the following.&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;from_date&lt;/TD&gt;&lt;TD&gt;to_date&lt;/TD&gt;&lt;TD&gt;drug&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;2017-03-01&lt;/TD&gt;&lt;TD&gt;2017-03-30&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;2017-03-01&lt;/TD&gt;&lt;TD&gt;2017-03-30&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;2017-03-15&lt;/TD&gt;&lt;TD&gt;2017-04-15&lt;/TD&gt;&lt;TD&gt;C_D&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;112&lt;/TD&gt;&lt;TD&gt;2017-08-10&lt;/TD&gt;&lt;TD&gt;2017-09-10&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;112&lt;/TD&gt;&lt;TD&gt;2017-08-10&lt;/TD&gt;&lt;TD&gt;2017-09-10&lt;/TD&gt;&lt;TD&gt;A_B&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to count the number of days for which one or more drugs are used. I use the following codes:&lt;/P&gt;&lt;P&gt;data expand;&lt;BR /&gt;set have;&lt;BR /&gt;do day=from_date to to_date;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table counted as&lt;BR /&gt;select *, count(distinct drug) as num_drug&lt;BR /&gt;from expand&lt;BR /&gt;group by id, day;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;The problem with this code is that I cannot know which combination people are in and also sometimes undercounts and overcounts the number of drugs used. In the above example, I would want the combination of A, B and C_D to be counted as four (C_D is a combination product which contains two drugs), but I get the count as three. To account for this I created another dataset using the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table new_counted as&lt;BR /&gt;select *, case when drug in ("A_B", "C_D") then num_drug+1&lt;BR /&gt;else num_drug end as new_count&lt;BR /&gt;from counted&lt;BR /&gt;group by id, day,new_count desc;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;This solves one problem but creates another. In the above example for id 112, it would give me a count of 3 which would be wrong (A and A_B should equal to two drug use). I am running in circles here. How could I get both number of days for total drugs use along with the type of combination? Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 03 May 2018 05:01:46 GMT</pubDate>
    <dc:creator>Mahip</dc:creator>
    <dc:date>2018-05-03T05:01:46Z</dc:date>
    <item>
      <title>Counting drug use overlap along with the type of combination</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Counting-drug-use-overlap-along-with-the-type-of-combination/m-p/459538#M14233</link>
      <description>&lt;P&gt;I have a dataset that looks like the following.&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;from_date&lt;/TD&gt;&lt;TD&gt;to_date&lt;/TD&gt;&lt;TD&gt;drug&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;2017-03-01&lt;/TD&gt;&lt;TD&gt;2017-03-30&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;2017-03-01&lt;/TD&gt;&lt;TD&gt;2017-03-30&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;2017-03-15&lt;/TD&gt;&lt;TD&gt;2017-04-15&lt;/TD&gt;&lt;TD&gt;C_D&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;112&lt;/TD&gt;&lt;TD&gt;2017-08-10&lt;/TD&gt;&lt;TD&gt;2017-09-10&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;112&lt;/TD&gt;&lt;TD&gt;2017-08-10&lt;/TD&gt;&lt;TD&gt;2017-09-10&lt;/TD&gt;&lt;TD&gt;A_B&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to count the number of days for which one or more drugs are used. I use the following codes:&lt;/P&gt;&lt;P&gt;data expand;&lt;BR /&gt;set have;&lt;BR /&gt;do day=from_date to to_date;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table counted as&lt;BR /&gt;select *, count(distinct drug) as num_drug&lt;BR /&gt;from expand&lt;BR /&gt;group by id, day;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;The problem with this code is that I cannot know which combination people are in and also sometimes undercounts and overcounts the number of drugs used. In the above example, I would want the combination of A, B and C_D to be counted as four (C_D is a combination product which contains two drugs), but I get the count as three. To account for this I created another dataset using the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table new_counted as&lt;BR /&gt;select *, case when drug in ("A_B", "C_D") then num_drug+1&lt;BR /&gt;else num_drug end as new_count&lt;BR /&gt;from counted&lt;BR /&gt;group by id, day,new_count desc;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;This solves one problem but creates another. In the above example for id 112, it would give me a count of 3 which would be wrong (A and A_B should equal to two drug use). I am running in circles here. How could I get both number of days for total drugs use along with the type of combination? Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 05:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Counting-drug-use-overlap-along-with-the-type-of-combination/m-p/459538#M14233</guid>
      <dc:creator>Mahip</dc:creator>
      <dc:date>2018-05-03T05:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Counting drug use overlap along with the type of combination</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Counting-drug-use-overlap-along-with-the-type-of-combination/m-p/459561#M14234</link>
      <description>&lt;P&gt;Post test data in the form of a datastep, I am not here to type in test data or guess formats.&amp;nbsp; I would say the steps are:&lt;/P&gt;
&lt;P&gt;1) Expand your current data creating a row for each drug, i.e. c_d would be split into two rows.&lt;/P&gt;
&lt;P&gt;2) Sort by drug&lt;/P&gt;
&lt;P&gt;3) datastep retain a count of days with a by group of drug&lt;/P&gt;</description>
      <pubDate>Thu, 03 May 2018 08:13:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Counting-drug-use-overlap-along-with-the-type-of-combination/m-p/459561#M14234</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-05-03T08:13:48Z</dc:date>
    </item>
  </channel>
</rss>

