<?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 If statement with and or in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306139#M65422</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying the below, which isn't the correct syntax&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if Funded_Trips =6 or Funded_Trips =4 then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if TripsCompleted &amp;lt; IMTarget or&amp;nbsp; if TripsCompleted &amp;lt; Target&amp;nbsp; then TargetMet= 'N'&lt;BR /&gt;&amp;nbsp; else 'Y' ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was hoping someone could give me the correct snytax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Haydn&lt;/P&gt;</description>
    <pubDate>Fri, 21 Oct 2016 01:15:23 GMT</pubDate>
    <dc:creator>Haydn</dc:creator>
    <dc:date>2016-10-21T01:15:23Z</dc:date>
    <item>
      <title>If statement with and or</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306139#M65422</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying the below, which isn't the correct syntax&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if Funded_Trips =6 or Funded_Trips =4 then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if TripsCompleted &amp;lt; IMTarget or&amp;nbsp; if TripsCompleted &amp;lt; Target&amp;nbsp; then TargetMet= 'N'&lt;BR /&gt;&amp;nbsp; else 'Y' ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was hoping someone could give me the correct snytax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Haydn&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 01:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306139#M65422</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2016-10-21T01:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: If statement with and or</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306166#M65431</link>
      <description>&lt;P&gt;Here's a possibility:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; if (Funded_Trips =6 or Funded_Trips =4) and&amp;nbsp;(&lt;/SPAN&gt;&lt;SPAN&gt;TripsCompleted &amp;lt; IMTarget or TripsCompleted &amp;lt; Target) then TargetMet= 'N';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; else TargetMet='Y' ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the right answer depends on when the ELSE condition should kick in. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 03:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306166#M65431</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-21T03:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: If statement with and or</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306167#M65432</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   if Funded_Trips in (4, 6) 
      and (TripsCompleted &amp;lt; IMTarget or  TripsCompleted &amp;lt; Target ) then TargetMet= 'N';
  else TargetMet='Y' ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Oct 2016 03:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306167#M65432</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-21T03:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: If statement with and or</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306171#M65435</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I suggest you activate the free Programming 1 course and review the DATA step language for conditional processing and how IF statements work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Without data, it is hard to know what you want to do, my tendency is to use AND and then use parentheses to group the OR conditions like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;if (Funded_Trips =6 or Funded_Trips =4) and &lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; (TripsCompleted &amp;lt; IMTarget or TripsCompleted &amp;lt; Target)&amp;nbsp; then TargetMet= 'N';&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;else TargetMet='Y' ;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;on the other hand, you could want:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;if (Funded_Trips =6 or Funded_Trips =4) then do;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if (TripsCompleted &amp;lt; IMTarget or TripsCompleted &amp;lt; Target) then do;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TargetMet= 'N';&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; end;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;else TargetMet='Y' ;&amp;nbsp; /* any other value for Funded_Trips gets TargetMet = Y */&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but, as I said, without data, and seeing what you have and what you want, it is hard to speculate. The above codes might or might not generate the desired results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 03:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306171#M65435</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-10-21T03:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: If statement with and or</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306215#M65448</link>
      <description>&lt;P&gt;Binary choices can be simplified with ifn/ifc functions:&lt;/P&gt;
&lt;PRE&gt;targetmet=ifc(funded_trips in (4,6) and tripscompleted &amp;lt; max(imtarget,target),'N','Y');&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Oct 2016 08:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306215#M65448</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-21T08:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: If statement with and or</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306293#M65476</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;&amp;nbsp;consider default length.&amp;nbsp; You would probably want to define the length of&amp;nbsp;"TARGETMET" and not let it default.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;25         data _null_;
26            x = ifc(1,'Y','N');
27            lx = vlength(x);
28            put _all_;
29            run;

x=Y lx=200 _ERROR_=0 _N_=1&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Oct 2016 14:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-with-and-or/m-p/306293#M65476</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-10-21T14:22:03Z</dc:date>
    </item>
  </channel>
</rss>

