<?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: identify IDs who have received both medications in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649578#M19239</link>
    <description>&lt;P&gt;I assumed your source is a SAS dataset. Is it excel? If yes, have you imported your excel into SAS yet?&lt;/P&gt;
&lt;P&gt;Once that is done, you could also consider the following boring predictable solution in my opinion&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
 do _n_=1 by 1 until(last.unique_id);
  set have;
  by unique_id;
  if n(statin) then _ns=statin;
  if n(aspirin) then _na=aspirin;
 end;
 _s=sum(_ns,_na);
 do _n_=1 to _n_;
  set have;
  if _s&amp;gt;=2 then output;
 end;
 drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 May 2020 14:19:38 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-05-21T14:19:38Z</dc:date>
    <item>
      <title>identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649568#M19235</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset for multiple records/ patient. Each record indicates a separate clinic visit for a certain patient identified by a unique id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;patient.&amp;nbsp; &amp;nbsp; &amp;nbsp;unique id&lt;/P&gt;
&lt;P&gt;patient 1-&amp;nbsp; abcd&lt;/P&gt;
&lt;P&gt;patient 2-&amp;nbsp; efgh&lt;/P&gt;
&lt;P&gt;patient 3.&amp;nbsp; &amp;nbsp;ijkl&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the data looks as follows&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;unique id&amp;nbsp; &amp;nbsp;clinic visit.&amp;nbsp; Aspirin&amp;nbsp; &amp;nbsp;statin&lt;/P&gt;
&lt;P&gt;abcd&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;abcd&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;abcd.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;abcd&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;efgh&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;efgh.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;efgh.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ijkl&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;ijkl&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ijkl&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;ijkl.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So looking at this, patients were either prescribed aspirin and statin on the same day (patient ijkl) or were only prescribe statin (patient efgh) or were prescribed both aspirin and statin but at different visits (patient abcd). My goal is to identify&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;patients who have been prescribed aspirin and statin regardless of the visit. For clarification, I would like to identify patients abcd and ijkl in this instance. My understanding is that if I use the "if aspirin=1 AND statin=1 then var1=1..." command it will look across each record individually and not consider that those records belong to a single patient.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Happy to provide more details&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;appreciate your help&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 13:59:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649568#M19235</guid>
      <dc:creator>GreenTree1</dc:creator>
      <dc:date>2020-05-21T13:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649573#M19236</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289922"&gt;@GreenTree1&lt;/a&gt;&amp;nbsp; Can you please provide a well formatted sample data that is usable to copy/paste and test. Well, here is a untested solution&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *
from have
group by unique_id
having sum(max(Aspirin),max(statin))&amp;gt;=2
order by unique_id,clinic_visit;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 May 2020 14:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649573#M19236</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-05-21T14:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649576#M19237</link>
      <description>Hi Novin,&lt;BR /&gt;Thank you, will an excel sheet work?&lt;BR /&gt;</description>
      <pubDate>Thu, 21 May 2020 14:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649576#M19237</guid>
      <dc:creator>GreenTree1</dc:creator>
      <dc:date>2020-05-21T14:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649577#M19238</link>
      <description>I can create an excel sheet of the data provided but wont be able to share the real data</description>
      <pubDate>Thu, 21 May 2020 14:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649577#M19238</guid>
      <dc:creator>GreenTree1</dc:creator>
      <dc:date>2020-05-21T14:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649578#M19239</link>
      <description>&lt;P&gt;I assumed your source is a SAS dataset. Is it excel? If yes, have you imported your excel into SAS yet?&lt;/P&gt;
&lt;P&gt;Once that is done, you could also consider the following boring predictable solution in my opinion&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
 do _n_=1 by 1 until(last.unique_id);
  set have;
  by unique_id;
  if n(statin) then _ns=statin;
  if n(aspirin) then _na=aspirin;
 end;
 _s=sum(_ns,_na);
 do _n_=1 to _n_;
  set have;
  if _s&amp;gt;=2 then output;
 end;
 drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 May 2020 14:19:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649578#M19239</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-05-21T14:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649581#M19240</link>
      <description>Hi novin, it is a sas dataset, I was just suggesting an excel format as I  thought that my posted question was not clear enough. &lt;BR /&gt;</description>
      <pubDate>Thu, 21 May 2020 14:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649581#M19240</guid>
      <dc:creator>GreenTree1</dc:creator>
      <dc:date>2020-05-21T14:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649587#M19241</link>
      <description>&lt;P&gt;Ah okay, I was only requesting a neat mock sample. lol. Nevermind. Have&amp;nbsp; you tested the code I provided with your real dataset yet?&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 14:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649587#M19241</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-05-21T14:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649598#M19243</link>
      <description>okay &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; , yes trying it now</description>
      <pubDate>Thu, 21 May 2020 15:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649598#M19243</guid>
      <dc:creator>GreenTree1</dc:creator>
      <dc:date>2020-05-21T15:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649604#M19244</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289922"&gt;@GreenTree1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Novin,&lt;BR /&gt;Thank you, will an excel sheet work?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box &lt;STRONG&gt;using the &amp;lt;/&amp;gt; icon&lt;/STRONG&gt; or attached as text to show exactly what you have and that we can test code against. The code box is important as the message windows on this forum will reformat plain text and the code often will not run properly when copied from the forum to a SAS session editor and executed.&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 15:22:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649604#M19244</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-21T15:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649900#M19248</link>
      <description>yayyy the first one worked. Thanks novin!</description>
      <pubDate>Fri, 22 May 2020 13:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649900#M19248</guid>
      <dc:creator>GreenTree1</dc:creator>
      <dc:date>2020-05-22T13:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: identify IDs who have received both medications</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649901#M19249</link>
      <description>Thanks Ballard,&lt;BR /&gt;Never tried this, I will give this a shot instead of typing it out</description>
      <pubDate>Fri, 22 May 2020 13:15:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/identify-IDs-who-have-received-both-medications/m-p/649901#M19249</guid>
      <dc:creator>GreenTree1</dc:creator>
      <dc:date>2020-05-22T13:15:17Z</dc:date>
    </item>
  </channel>
</rss>

