<?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 what is  the difference between If and Where Stmt in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-Stmt/m-p/16276#M2268</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
   When I put the following logic&lt;BR /&gt;
&lt;BR /&gt;
IF  SUBSTR(TRIM(LEFT(BRPROV)),1,7) = 'ALBERTA'  OR&lt;BR /&gt;
 (SUBSTR(TRIM(LEFT(BRPROV)),1,12) = 'SASKATCHEWAN'&lt;BR /&gt;
&lt;BR /&gt;
I got the following messge&lt;BR /&gt;
&lt;BR /&gt;
INVALID THIRD ARGUMENT TO FUNCTION SUBSTR AT LINE 302 COLUMN 3.&lt;BR /&gt;
&lt;BR /&gt;
When I put &lt;BR /&gt;
WHERE  SUBSTR(TRIM(LEFT(BRPROV)),1,7) = 'ALBERTA'  OR&lt;BR /&gt;
 (SUBSTR(TRIM(LEFT(BRPROV)),1,12) = 'SASKATCHEWAN' &lt;BR /&gt;
&lt;BR /&gt;
I don't get any error message.&lt;BR /&gt;
&lt;BR /&gt;
Can any one please explain to me Why such error message comming?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Inpda</description>
    <pubDate>Thu, 08 May 2008 00:09:10 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-05-08T00:09:10Z</dc:date>
    <item>
      <title>what is  the difference between If and Where Stmt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-Stmt/m-p/16276#M2268</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
   When I put the following logic&lt;BR /&gt;
&lt;BR /&gt;
IF  SUBSTR(TRIM(LEFT(BRPROV)),1,7) = 'ALBERTA'  OR&lt;BR /&gt;
 (SUBSTR(TRIM(LEFT(BRPROV)),1,12) = 'SASKATCHEWAN'&lt;BR /&gt;
&lt;BR /&gt;
I got the following messge&lt;BR /&gt;
&lt;BR /&gt;
INVALID THIRD ARGUMENT TO FUNCTION SUBSTR AT LINE 302 COLUMN 3.&lt;BR /&gt;
&lt;BR /&gt;
When I put &lt;BR /&gt;
WHERE  SUBSTR(TRIM(LEFT(BRPROV)),1,7) = 'ALBERTA'  OR&lt;BR /&gt;
 (SUBSTR(TRIM(LEFT(BRPROV)),1,12) = 'SASKATCHEWAN' &lt;BR /&gt;
&lt;BR /&gt;
I don't get any error message.&lt;BR /&gt;
&lt;BR /&gt;
Can any one please explain to me Why such error message comming?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Inpda</description>
      <pubDate>Thu, 08 May 2008 00:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-Stmt/m-p/16276#M2268</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-08T00:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: what is  the difference between If and Where Stmt</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-Stmt/m-p/16277#M2269</link>
      <description>Hi:&lt;BR /&gt;
  I can't duplicate your error message. When I run this code:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data testfile;&lt;BR /&gt;
length BRPROV $15;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input BRPROV $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
ALBERTA&lt;BR /&gt;
SASKATCHEWAN&lt;BR /&gt;
SASKATOON&lt;BR /&gt;
MANITOBA&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
     &lt;BR /&gt;
data ifstmt;&lt;BR /&gt;
  set testfile;&lt;BR /&gt;
IF SUBSTR(TRIM(LEFT(BRPROV)),1,7) = 'ALBERTA' OR&lt;BR /&gt;
  (SUBSTR(TRIM(LEFT(BRPROV)),1,12) = 'SASKATCHEWAN'; &lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
I get a different error message from the mismatched parentheses in the second SUBSTR function. You have 3 open parens and 3 close parens in the test for ALBERTA, but you have &lt;B&gt;4&lt;/B&gt; open parens and only &lt;B&gt; 3&lt;/B&gt; close parens in the test for SASKATCHEWAN.&lt;BR /&gt;
[pre]&lt;BR /&gt;
1386  data ifstmt;&lt;BR /&gt;
1387    set testfile;&lt;BR /&gt;
1388  IF SUBSTR(TRIM(LEFT(BRPROV)),1,7) = 'ALBERTA' OR&lt;BR /&gt;
1389    (SUBSTR(TRIM(LEFT(BRPROV)),1,12) = 'SASKATCHEWAN';&lt;BR /&gt;
                                                         -&lt;BR /&gt;
                                                         79&lt;BR /&gt;
ERROR 79-322: Expecting a ).&lt;BR /&gt;
&lt;BR /&gt;
1390  run;&lt;BR /&gt;
        &lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
WARNING: The data set WORK.IFSTMT may be incomplete.  When this step was stopped there were 0 observations and 1&lt;BR /&gt;
         variables.&lt;BR /&gt;
WARNING: Data set WORK.IFSTMT was not replaced because this step was stopped.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
   &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
And, when I run a PROC PRINT with a WHERE statement, I get the SAME error message about the mismatched parens.&lt;BR /&gt;
[pre]&lt;BR /&gt;
1395&lt;BR /&gt;
1396  proc print data=testfile;&lt;BR /&gt;
1397  WHERE SUBSTR(TRIM(LEFT(BRPROV)),1,7) = 'ALBERTA' OR&lt;BR /&gt;
1398       (SUBSTR(TRIM(LEFT(BRPROV)),1,12) = 'SASKATCHEWAN' ;&lt;BR /&gt;
                                                             -&lt;BR /&gt;
                                                             79&lt;BR /&gt;
ERROR 79-322: Expecting a ).&lt;BR /&gt;
1399  title 'using WHERE statement';&lt;BR /&gt;
ERROR: Syntax error while parsing WHERE clause.&lt;BR /&gt;
1400  run;&lt;BR /&gt;
    &lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
     &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Rather than just posting partial code snippets, you may be helped more by contacting Tech Support and showing them your complete code, your entire SAS log. They can probably help you figure out the problem in a more timely fashion.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 08 May 2008 03:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-Stmt/m-p/16277#M2269</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-05-08T03:08:07Z</dc:date>
    </item>
  </channel>
</rss>

