<?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: seeing unexpected output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933848#M367268</link>
    <description>&lt;P&gt;That is not the result we get from your current code because that is not what your current code is asking for.&amp;nbsp; You asked for this output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1719427774086.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97921iE0095C3DD97DCDD0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1719427774086.png" alt="Tom_0-1719427774086.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Notice how every observation selected has NO for at least one of the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you only want the observations that are NO on every variable (or not YES) then use AND as the conjunction instead of OR.&amp;nbsp; Note: Make your code easier to read by putting the conjunction string are the start of the line instead of the end.&amp;nbsp; It is much, much easier for humans to scan the nice smooth left edge of the lines than the jagged right edge of the lines.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
select * from tesl 
where status1 not in ('yes')
  and status2 not in ('yes')
  and status3 not in ('yes')
  and status4 not in ('yes')
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jun 2024 18:52:14 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-06-26T18:52:14Z</dc:date>
    <item>
      <title>seeing unexpected output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933842#M367266</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have data set as below and wanted to see where all columns have values 'no' . Tried below code but didn't work.&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;ID status1 status2 status3 status4 &lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;yes&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data tesl;
infile datalines ;
input ID status1 $ status2 $ status3 $ status4 $;
datalines ;
1 yes no  no  yes
2 no  yes no  yes
3 yes yes no  no
4 no  no  no  no
5 no  no  yes no
;
run;

proc sql;
select * from tesl 
where status1 not in ('yes') or
status2 not in ('yes') or 
status3 not in ('yes') or 
status4 not in ('yes')
;
quit;
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;output should be :&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;status1&lt;/TD&gt;&lt;TD&gt;status2&lt;/TD&gt;&lt;TD&gt;status3&lt;/TD&gt;&lt;TD&gt;status4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;TD&gt;no&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;kajal&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 26 Jun 2024 18:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933842#M367266</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2024-06-26T18:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: seeing unexpected output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933846#M367267</link>
      <description>&lt;P&gt;If that's what you want, why don't you program it directly like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select * from tesl 
where status1 eq 'no' and
status2 eq 'no' and
status3 eq 'no' and
status4 eq 'no' 
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or possibly you meant this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select * from tesl 
where status1 not in ('yes') and
status2 not in ('yes') and 
status3 not in ('yes') and 
status4 not in ('yes')
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but the second block of code is logically equivalent to the first block of code (when there are only two possible values 'yes' and 'no'), so save yourself some typing and use the first block of code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, do yourself a favor and represent 'yes' with a numeric 1 and 'no' with a numeric zero. Not only is this less typing, but its fewer opportunities for typographical errors (at least, the way I type) and then the programming is even easier&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set tesl;
    where sum(of status1-status4)=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 19:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933846#M367267</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-26T19:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: seeing unexpected output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933848#M367268</link>
      <description>&lt;P&gt;That is not the result we get from your current code because that is not what your current code is asking for.&amp;nbsp; You asked for this output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1719427774086.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97921iE0095C3DD97DCDD0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1719427774086.png" alt="Tom_0-1719427774086.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Notice how every observation selected has NO for at least one of the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you only want the observations that are NO on every variable (or not YES) then use AND as the conjunction instead of OR.&amp;nbsp; Note: Make your code easier to read by putting the conjunction string are the start of the line instead of the end.&amp;nbsp; It is much, much easier for humans to scan the nice smooth left edge of the lines than the jagged right edge of the lines.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
select * from tesl 
where status1 not in ('yes')
  and status2 not in ('yes')
  and status3 not in ('yes')
  and status4 not in ('yes')
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 18:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933848#M367268</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-06-26T18:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: seeing unexpected output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933850#M367269</link>
      <description>&lt;P&gt;Another way assumes all fields are either yes or no.&amp;nbsp; &amp;nbsp;Probably not realistic scenario.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   infile datalines ;
   input ID (status1-status4)($);
   datalines ;
1 yes no  no  yes
2 no  yes no  yes
3 yes yes no  no
4 no  no  no  no
5 no  no  yes no
;
run;

data allno;
   set test;
   allno = not whichc('yes',of status:);
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 297px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97922i119FD16F1289C502/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 18:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933850#M367269</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-06-26T18:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: seeing unexpected output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933868#M367276</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   infile datalines ;
   input ID (status1-status4)($);
   datalines ;
1 yes no  no  yes
2 no  yes no  yes
3 yes yes no  no
4 no  no  no  no
5 no  no  yes no
;
run;

data allno;
   set test;
if sum(status1='no',status2='no',status3='no',status4='no')=4;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Jun 2024 02:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seeing-unexpected-output/m-p/933868#M367276</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-06-27T02:18:06Z</dc:date>
    </item>
  </channel>
</rss>

