<?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 Need help with logic in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899216#M355427</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the below logic and confused on how to include 'AND 'and 'OR' within same if statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ed azm azn azo azp azq azr azs azt azu azv azw azx azy azz baa bab bac bae baf bag bah bai baj bak bal bam ban bao bap baq bar bas bat bau"&gt;If&lt;BR /&gt;((HAT = 'Yes'&amp;nbsp;Or&amp;nbsp;SAT = 'Yes' Or&amp;nbsp;TBP = 'Yes')&amp;nbsp;Or&amp;nbsp;(TBI = 'Yes'&amp;nbsp;And&amp;nbsp;REC = 'Yes')&amp;nbsp;Or&amp;nbsp;COT = Yes)&amp;nbsp;And&lt;BR /&gt;RESULT = 'Pos'&amp;nbsp;And&amp;nbsp;Does not satisfy (CAT = 'XCL' and TEST = 27)&amp;nbsp;then output&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ed azm azn azo azp azq azr azs azt azu azv azw azx azy azz baa bab bac bae baf bag bah bai baj bak bal bam ban bao bap baq bar bas bat bau"&gt;The above variables with given values should satisfy so that i get the desired output from the given raw data.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ed azm azn azo azp azq azr azs azt azu azv azw azx azy azz baa bab bac bae baf bag bah bai baj bak bal bam ban bao bap baq bar bas bat bau"&gt;Any help with how to write the program to satisfy the logic?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2023 10:45:22 GMT</pubDate>
    <dc:creator>r3570</dc:creator>
    <dc:date>2023-10-19T10:45:22Z</dc:date>
    <item>
      <title>Need help with logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899216#M355427</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the below logic and confused on how to include 'AND 'and 'OR' within same if statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ed azm azn azo azp azq azr azs azt azu azv azw azx azy azz baa bab bac bae baf bag bah bai baj bak bal bam ban bao bap baq bar bas bat bau"&gt;If&lt;BR /&gt;((HAT = 'Yes'&amp;nbsp;Or&amp;nbsp;SAT = 'Yes' Or&amp;nbsp;TBP = 'Yes')&amp;nbsp;Or&amp;nbsp;(TBI = 'Yes'&amp;nbsp;And&amp;nbsp;REC = 'Yes')&amp;nbsp;Or&amp;nbsp;COT = Yes)&amp;nbsp;And&lt;BR /&gt;RESULT = 'Pos'&amp;nbsp;And&amp;nbsp;Does not satisfy (CAT = 'XCL' and TEST = 27)&amp;nbsp;then output&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ed azm azn azo azp azq azr azs azt azu azv azw azx azy azz baa bab bac bae baf bag bah bai baj bak bal bam ban bao bap baq bar bas bat bau"&gt;The above variables with given values should satisfy so that i get the desired output from the given raw data.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ed azm azn azo azp azq azr azs azt azu azv azw azx azy azz baa bab bac bae baf bag bah bai baj bak bal bam ban bao bap baq bar bas bat bau"&gt;Any help with how to write the program to satisfy the logic?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 10:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899216#M355427</guid>
      <dc:creator>r3570</dc:creator>
      <dc:date>2023-10-19T10:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899218#M355428</link>
      <description>&lt;P&gt;Questions like this is much easier to answer if you provide a minimum of sample data and your desired result.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 11:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899218#M355428</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-10-19T11:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899219#M355429</link>
      <description>&lt;P&gt;Thanks for your reply&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please consider the below data as the raw data. Consider the first column as ID and rest are the variables in order HAT SAT&amp;nbsp;TBP TBI REC COT RESULT CAT TEST with corresponding values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;202359 No&amp;nbsp; &amp;nbsp;No&amp;nbsp; No No&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes Pos XCL 26.0&lt;BR /&gt;202360 Yes Yes Yes Yes Yes Yes Pos XCL 27.0&lt;BR /&gt;202360 Yes Yes Yes Yes Yes Yes Pos ICL&amp;nbsp; 27.0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My output should be the below record not the rest.&lt;/P&gt;
&lt;P&gt;202359 No&amp;nbsp; &amp;nbsp;No&amp;nbsp; No No&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes Pos XCL 26.0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 11:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899219#M355429</guid>
      <dc:creator>r3570</dc:creator>
      <dc:date>2023-10-19T11:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899229#M355435</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I've understood your requirements, for the record you want I have created the following code. Is this what you're looking for?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input
    @01 id     $char6.
    @08 HAT    $char3.
    @12 SAT    $char3.
    @16 TBP    $char3.
    @20 TBI    $char3.
    @24 REC    $char3.
    @28 COT    $char3.
    @32 RESULT $char3.
    @36 CAT    $char3.
    @40 TEST        8.
  ;
  
  datalines;
202359 No  No  No  No      Yes Pos XCL 26.0
202360 Yes Yes Yes Yes Yes Yes Pos XCL 27.0
202360 Yes Yes Yes Yes Yes Yes Pos ICL 27.0
;


data want;
  set have;

  if (
         (HAT = 'Yes' or SAT = 'Yes' or TBP = 'Yes')
      or (TBI = 'Yes' and REC = 'Yes')
      or COT = 'Yes'
     )
     and RESULT = 'Pos'
     and CAT = 'XCL'
     and TEST = 26
  ;
run;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 12:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899229#M355435</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2023-10-19T12:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899251#M355447</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;&lt;SPAN class="ui-provider ed azm azn azo azp azq azr azs azt azu azv azw azx azy azz baa bab bac bae baf bag bah bai baj bak bal bam ban bao bap baq bar bas bat bau"&gt;And&amp;nbsp;Does not satisfy (CAT = 'XCL' and TEST = 27)&lt;/SPAN&gt;&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;would be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And Not &lt;SPAN&gt;&lt;SPAN class="ui-provider ed azm azn azo azp azq azr azs azt azu azv azw azx azy azz baa bab bac bae baf bag bah bai baj bak bal bam ban bao bap baq bar bas bat bau"&gt;(CAT = 'XCL' and TEST = 27) )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ed azm azn azo azp azq azr azs azt azu azv azw azx azy azz baa bab bac bae baf bag bah bai baj bak bal bam ban bao bap baq bar bas bat bau"&gt;NOT is an operator to negate the result of a logical operation. If (CAT = 'XCL' and TEST = 27) is "true" then not(CAT = 'XCL' and TEST = 27) is "false".&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ed azm azn azo azp azq azr azs azt azu azv azw azx azy azz baa bab bac bae baf bag bah bai baj bak bal bam ban bao bap baq bar bas bat bau"&gt;With out know the expected result for some given values it is hard to tell if the rest of your logic is correct or not.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 14:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899251#M355447</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-19T14:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899285#M355458</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/382012"&gt;@r3570&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please consider the below data as the raw data. Consider the first column as ID and rest are the variables in order HAT SAT&amp;nbsp;TBP TBI REC COT RESULT CAT TEST with corresponding values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;202359 No&amp;nbsp; &amp;nbsp;No&amp;nbsp; No No&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes Pos XCL 26.0&lt;BR /&gt;202360 Yes Yes Yes Yes Yes Yes Pos XCL 27.0&lt;BR /&gt;202360 Yes Yes Yes Yes Yes Yes Pos ICL&amp;nbsp; 27.0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My output should be the below record not the rest.&lt;/P&gt;
&lt;P&gt;202359 No&amp;nbsp; &amp;nbsp;No&amp;nbsp; No No&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes Pos XCL 26.0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In your first post, your criteria included&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;And&amp;nbsp;Does not satisfy (CAT = 'XCL' and TEST = 27)&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;which, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;said, would be expressed as&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;NOT (CAT = 'XCL' and TEST = 27)&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;But that would not produce a single output as you want.&amp;nbsp; There would be 2 output observations from this condition.&amp;nbsp; So what do you mean by&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;And&amp;nbsp;Does not satisfy (CAT = 'XCL' and TEST = 27)&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 15:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-logic/m-p/899285#M355458</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-10-19T15:50:04Z</dc:date>
    </item>
  </channel>
</rss>

