<?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: how to filter data to check which subject has that particular treatmnet or not? in SAS Software for Learning Community</title>
    <link>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/882141#M1308</link>
    <description>&lt;P&gt;As a general heuristic using a DATA step, what I would do here is:&lt;BR /&gt;1. Create a dataset with subjects that took the first treatment.&lt;/P&gt;
&lt;P&gt;2. Create a dataset with subjects that took the second treatment.&lt;/P&gt;
&lt;P&gt;3. Merge those datasets together to form a third dataset. When doing that, use IN= dataset options, so you know which subjects came from which dataset.&lt;/P&gt;
&lt;P&gt;4. Output from the third dataset only those subjects that appeared in exactly one of the datasets.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;These steps could be combined into one DATA step, so something like:&lt;BR /&gt;&lt;BR /&gt;proc sort data=original_data out=one(keep=subject trt) nodupkey;&lt;/P&gt;
&lt;P&gt;by subject trt;&lt;/P&gt;
&lt;P&gt;run;&lt;BR /&gt;&lt;BR /&gt;data three;&lt;/P&gt;
&lt;P&gt;merge one(where=(trt="TRT1") in=in1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;one(where=(trt="TRT2") in=in2);&lt;/P&gt;
&lt;P&gt;by subject;&lt;/P&gt;
&lt;P&gt;if sum(in1,in2)=1;&lt;/P&gt;
&lt;P&gt;keep subject;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Jun 2023 14:23:35 GMT</pubDate>
    <dc:creator>JackieJ_SAS</dc:creator>
    <dc:date>2023-06-23T14:23:35Z</dc:date>
    <item>
      <title>how to filter data to check which subject has that particular treatmnet or not?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/881934#M1304</link>
      <description>&lt;P&gt;I want to filter data according to if particular subject has treatment like "onsite administration" or "dose administration" I want to filter those subjects who has only "on site administation" only. some subjects have both treatment and some subjects has only one treatment. I want to filter only those subjects which have only one treatment. if i filter data like extrt="on site administration" then those subjects will get filtered which has taken both treatment. I want only those subject which has taken only "on site treatment" I have attached screenshot for better understanding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dose tratement.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85254iF19C8E41E4A84969/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dose tratement.png" alt="dose tratement.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 15:48:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/881934#M1304</guid>
      <dc:creator>srmakwana2009</dc:creator>
      <dc:date>2023-06-22T15:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to filter data to check which subject has that particular treatmnet or not?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/881986#M1305</link>
      <description>&lt;P&gt;You need to aggregate to the test.&amp;nbsp; MIN() and MAX() work well for BOOLEAN values.&amp;nbsp; If the MAX() is TRUE then at least one of the values is TRUE.&amp;nbsp; If the MIN() is TRUE then all of the values are TRUE. If the MAX() is FALSE then none of the values are TRUE.&amp;nbsp; If the MIN() is FALSE then at least one of the values is FALSE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So to test if ALL of the values are&amp;nbsp;&lt;SPAN&gt;on site administration the do something like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select subjid 
     , min(lowcase(EXCAT)='on site administration') as ON_SITE
from have
group by subjid
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;So ON_SITE will be TRUE (have a value of 1) when every observation for that SUBJID was&amp;nbsp;on site administration and FALSE (have a value of zero) otherwise.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: If you want to filter individual observations based on attributes derived from groups of observations then you will need to process the data twice.&amp;nbsp; Once to calculate the value you need to select the group you then need to remerge that value back onto all off the observations in the group.&amp;nbsp; Either by using two steps or perhaps taking advantage of PROC SQL's ability to automatically remerge aggregate statistics back onto all observations in the group.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table ON_SITE as 
select *
from have
group by subjid
having min(lowcase(EXCAT)='on site administration')
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 17:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/881986#M1305</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-22T17:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to filter data to check which subject has that particular treatmnet or not?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/882141#M1308</link>
      <description>&lt;P&gt;As a general heuristic using a DATA step, what I would do here is:&lt;BR /&gt;1. Create a dataset with subjects that took the first treatment.&lt;/P&gt;
&lt;P&gt;2. Create a dataset with subjects that took the second treatment.&lt;/P&gt;
&lt;P&gt;3. Merge those datasets together to form a third dataset. When doing that, use IN= dataset options, so you know which subjects came from which dataset.&lt;/P&gt;
&lt;P&gt;4. Output from the third dataset only those subjects that appeared in exactly one of the datasets.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;These steps could be combined into one DATA step, so something like:&lt;BR /&gt;&lt;BR /&gt;proc sort data=original_data out=one(keep=subject trt) nodupkey;&lt;/P&gt;
&lt;P&gt;by subject trt;&lt;/P&gt;
&lt;P&gt;run;&lt;BR /&gt;&lt;BR /&gt;data three;&lt;/P&gt;
&lt;P&gt;merge one(where=(trt="TRT1") in=in1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;one(where=(trt="TRT2") in=in2);&lt;/P&gt;
&lt;P&gt;by subject;&lt;/P&gt;
&lt;P&gt;if sum(in1,in2)=1;&lt;/P&gt;
&lt;P&gt;keep subject;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 14:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/882141#M1308</guid>
      <dc:creator>JackieJ_SAS</dc:creator>
      <dc:date>2023-06-23T14:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to filter data to check which subject has that particular treatmnet or not?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/882567#M1310</link>
      <description>&lt;P&gt;Thank you so much&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 03:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/882567#M1310</guid>
      <dc:creator>srmakwana2009</dc:creator>
      <dc:date>2023-06-27T03:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to filter data to check which subject has that particular treatmnet or not?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/882568#M1311</link>
      <description>&lt;P&gt;Thank you so much . it helped a lot&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 03:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/how-to-filter-data-to-check-which-subject-has-that-particular/m-p/882568#M1311</guid>
      <dc:creator>srmakwana2009</dc:creator>
      <dc:date>2023-06-27T03:01:05Z</dc:date>
    </item>
  </channel>
</rss>

