<?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 Create a logic statement for &amp;quot;all subgroup treatments are either missing or NO&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895460#M353800</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to create an error check table with a logic statement below. Please use Proc SQL format and help me&amp;nbsp;complete the Where statement.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a treatment (meds) = 1 (Yes), I'm look for any subgroups (steroids/vaso/immunemods/monoclonal/ antiviral/othertx) are either missing (.) or No (0).&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 meds, steroids, vaso, immunemods, monoclonal, antiviral, othertx
from have
where meds=1 and (???)
order by site;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Sep 2023 15:02:31 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2023-09-22T15:02:31Z</dc:date>
    <item>
      <title>Create a logic statement for "all subgroup treatments are either missing or NO"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895460#M353800</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to create an error check table with a logic statement below. Please use Proc SQL format and help me&amp;nbsp;complete the Where statement.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a treatment (meds) = 1 (Yes), I'm look for any subgroups (steroids/vaso/immunemods/monoclonal/ antiviral/othertx) are either missing (.) or No (0).&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 meds, steroids, vaso, immunemods, monoclonal, antiviral, othertx
from have
where meds=1 and (???)
order by site;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 15:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895460#M353800</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2023-09-22T15:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create a logic statement for "all subgroup treatments are either missing or NO"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895461#M353801</link>
      <description>What should NMISS, N, SUM be for this set of variables if your condition is true?</description>
      <pubDate>Fri, 22 Sep 2023 15:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895461#M353801</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-09-22T15:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create a logic statement for "all subgroup treatments are either missing or NO"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895463#M353802</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I would like to create an error check table with a logic statement below. Please use Proc SQL format and help me&amp;nbsp;complete the Where statement.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a treatment (meds) = 1 (Yes), I'm look for any subgroups (steroids/vaso/immunemods/monoclonal/ antiviral/othertx) are either missing (.) or No (0).&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 meds, steroids, vaso, immunemods, monoclonal, antiviral, othertx
from have
where meds=1 and (???)
order by site;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So your variables are Boolean (1=TRUE and 0=FALSE) with some missing values?&lt;/P&gt;
&lt;P&gt;If so your test is the condition that it is NOT true that ALL of them are TRUE. So test if the SUM() of them is not equal to the number of variables.&amp;nbsp; (Note you cannot just test if the MIN() is equal to 1 since MIN() will ignore the missing values.)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where meds and (6 ne sum(steroids, vaso, immunemods, monoclonal, antiviral, othertx))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But perhaps you just didn't describe what you want clearly?&amp;nbsp; It would make more sense to me to look for the observations where MEDS is TRUE but all of the other variables is FALSE as that seems to indicate an inconsistency.&amp;nbsp; So the MAX() will be TRUE if ANY of them is TRUE.&amp;nbsp; So in that case the problem records are those with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where meds and not max(steroids, vaso, immunemods, monoclonal, antiviral, othertx)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 15:29:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895463#M353802</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-22T15:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create a logic statement for "all subgroup treatments are either missing or NO"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895464#M353803</link>
      <description>&lt;P&gt;I don't think I grasp the problem. When you say&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I'm look for any subgroups (steroids/vaso/immunemods/monoclonal/ antiviral/othertx) are either missing (.) or No (0).&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by subgroup?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your title says you want ALL subgroup treatments, but your text says you want ANY subgroups. Which is it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you show us (or make up) a small amount of data, along with the desired output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 15:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895464#M353803</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-09-22T15:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create a logic statement for "all subgroup treatments are either missing or NO"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895467#M353805</link>
      <description>&lt;P&gt;Just a style note. This is an extremely simple appearing query BUT you may find it easier to use a data step in the long run with some things like this, especially if you end up needing to use the same list of variables multiple time.&lt;/P&gt;
&lt;P&gt;The data step would let you use either an array or possibly the two dash list if all of your steroids to othertx variables are adjacent in the data set. SQL won't allow either shortcut.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider that answering &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s question about the N, Nmiss and Sum of the variables.&lt;/P&gt;
&lt;PRE&gt;data want;
    set have;
    array v(*) steroids vaso immunemods monoclonal antiviral othertx;
    listn = n(of v(*) );
    listnmiss = nmiss( of v(*) );
    listsum  = sum(of v(*) );&lt;BR /&gt;    if meds=1 and ( min(of v(*))=0 or listnmiss&amp;gt;0); /* maybe coding your statment relatively directly*/&lt;BR /&gt;    /* or alternately as if at least one of the variables is 0 or missing the sum is less than 6&lt;BR /&gt;    if meds=1 and sum( of v(*)) &amp;lt; 6;&lt;BR /&gt;   */
run;&lt;/PRE&gt;
&lt;P&gt;With SQL you have to explicitly type the names of all of the variables into the function parameters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Likely if the set is "large" the data step will run quicker as well.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 16:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895467#M353805</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-22T16:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create a logic statement for "all subgroup treatments are either missing or NO"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895468#M353806</link>
      <description>&lt;P&gt;Thank you so much for your help.&amp;nbsp; I got it.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 16:31:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-logic-statement-for-quot-all-subgroup-treatments-are/m-p/895468#M353806</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2023-09-22T16:31:42Z</dc:date>
    </item>
  </channel>
</rss>

