<?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: Assigning treatment groups in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-treatment-groups/m-p/132422#M36028</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So you want to create a patient level flag?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input id drug $ old_flag;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 A 1&lt;/P&gt;&lt;P&gt;1 B 0&lt;/P&gt;&lt;P&gt;2 B 0&lt;/P&gt;&lt;P&gt;2 B 0&lt;/P&gt;&lt;P&gt;2 C 0&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (last.id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if drug in ("A") then new_flag = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; new_flag = coalesce(new_flag,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; keep id new_flag ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put (id new_flag) (=) ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id=1 new_flag=1&lt;/P&gt;&lt;P&gt;id=2 new_flag=0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Sep 2013 19:12:16 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2013-09-09T19:12:16Z</dc:date>
    <item>
      <title>Assigning treatment groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-treatment-groups/m-p/132420#M36026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to assign treatments of "_drug_of_interest_" and "_not drug of interest_" to my data set. I have one data set of "drug data" where I can assign an indicator variable of "drug" and "not drug." This needs to be merged with my data set of "clinical data" where I can then separate all data I have on those ids into treatment groups. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I've tried so far:&lt;/P&gt;&lt;P&gt;I assigned my indicator variable of 1's and 0's to my drug data set and merged that with the clinical data then subset the data by that indicator variable. When I subset the data I get the correct number of ids assigned to my drug of interest data set (I know this number), the control group though turns out to be all the ids in the list because they were treated with multiple drugs. Below is a sample:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="155" style="border: 1px solid rgb(0, 0, 0); width: 329px; height: 157px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;id&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;drug&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;indicator&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;C&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assume A is my drug of interest. I would like to make a list of all ids that received drug A and a list of all ids that did not receive A. If an id can have a 1 as an indicator I would like to take out all data rows belonging to that patient and place them into a separate list, that way there is no overlap in patients. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I posting in the right community? Is more information necessary? Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank You.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 18:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-treatment-groups/m-p/132420#M36026</guid>
      <dc:creator>rrevans</dc:creator>
      <dc:date>2013-09-09T18:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning treatment groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-treatment-groups/m-p/132421#M36027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table drugAlist as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where indicator = 1 &lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table notdrugAlist as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where id not in&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ( select id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from drugAlist )&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 18:40:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-treatment-groups/m-p/132421#M36027</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2013-09-09T18:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning treatment groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-treatment-groups/m-p/132422#M36028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So you want to create a patient level flag?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input id drug $ old_flag;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 A 1&lt;/P&gt;&lt;P&gt;1 B 0&lt;/P&gt;&lt;P&gt;2 B 0&lt;/P&gt;&lt;P&gt;2 B 0&lt;/P&gt;&lt;P&gt;2 C 0&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (last.id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by id ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if drug in ("A") then new_flag = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; new_flag = coalesce(new_flag,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; keep id new_flag ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put (id new_flag) (=) ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id=1 new_flag=1&lt;/P&gt;&lt;P&gt;id=2 new_flag=0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Sep 2013 19:12:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-treatment-groups/m-p/132422#M36028</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-09-09T19:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning treatment groups</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-treatment-groups/m-p/132423#M36029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for this. I did not think this would work as well as it did. I did have to merge this list back to the original once I had the flags in place to gather all the data in one list. I tried both methods given here by yourself and Tom and both achieve the same result. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2013 16:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-treatment-groups/m-p/132423#M36029</guid>
      <dc:creator>rrevans</dc:creator>
      <dc:date>2013-09-10T16:06:41Z</dc:date>
    </item>
  </channel>
</rss>

