<?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: what is the difference between If and Where statment.b in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-statment-b/m-p/17113#M2441</link>
    <description>Hi:&lt;BR /&gt;
  I note you still have the missing parentheses that I noted in my other forum posting on this subject:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=11428Ⲥ" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=11428Ⲥ&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
  This statement has [pre]&lt;BR /&gt;
302    (SUBSTR(TRIM(LEFT(BRPROV)),1,12) = 'SASKATCHEWAN' AND&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
4 open parens and just 3 close parens. As I said in the previous post, I could not duplicate your error message.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
    <pubDate>Sun, 11 May 2008 07:14:15 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2008-05-11T07:14:15Z</dc:date>
    <item>
      <title>what is the difference between If and Where statment.b</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-statment-b/m-p/17112#M2440</link>
      <description>Hi &lt;BR /&gt;
Here is my actual coding &lt;BR /&gt;
&lt;BR /&gt;
299        DATA BUNDRPT REGULERT;&lt;BR /&gt;
300        SET COMBINE;&lt;BR /&gt;
301        IF (SUBSTR(TRIM(LEFT(BRPROV)),1,7) = 'ALBERTA') OR&lt;BR /&gt;
302         (SUBSTR(TRIM(LEFT(BRPROV)),1,12) = 'SASKATCHEWAN' AND&lt;BR /&gt;
303         PUT(CIDKEY,SASK.) = 'Y') THEN OUTPUT BUNDRPT;&lt;BR /&gt;
304         ELSE OUTPUT REGULERT;&lt;BR /&gt;
305         RUN;&lt;BR /&gt;
&lt;BR /&gt;
Error messages&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;NOTE: INVALID THIRD ARGUMENT TO FUNCTION SUBSTR AT LINE 302 COLUMN 3.&lt;/B&gt;&lt;BR /&gt;
CIDKEY=1111111111111111 ACCOUNT=000000111111111 ORIGDATE=04JUL2003 ISSUEDTE=04JUL2003 MATDATE=04JUL2008 BLTRANS=77777 &lt;B&gt;BRPROV=ALBERTA&lt;/B&gt;&lt;BR /&gt;
CUSTNM=xxxxxxxxxxxxx MKEY=vvvvvvvvvvv NAME=cccccccccc CADD1=eeeeeee CADD2=rrrrrrrrrr cccc MY T1A 7H3&lt;BR /&gt;
&lt;BR /&gt;
IF I PUT WHERE STATMENT instead of IF, I don't get errory message.&lt;BR /&gt;
&lt;BR /&gt;
What make the difference between &lt;B&gt;if&lt;/B&gt; and &lt;B&gt;where&lt;/B&gt; statment.&lt;BR /&gt;
&lt;BR /&gt;
Note that field BRPROV is 18 characters length long&lt;BR /&gt;
thanks&lt;BR /&gt;
(from the proc contents I found the following&lt;BR /&gt;
#    Variable    Type    Len     Pos    Format    Label   &lt;BR /&gt;
44   BRPROV      CHAR     18     320&lt;BR /&gt;
)&lt;BR /&gt;
&lt;BR /&gt;
Anton

Message was edited by: Inp</description>
      <pubDate>Sun, 11 May 2008 04:48:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-statment-b/m-p/17112#M2440</guid>
      <dc:creator>Inp</dc:creator>
      <dc:date>2008-05-11T04:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: what is the difference between If and Where statment.b</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-statment-b/m-p/17113#M2441</link>
      <description>Hi:&lt;BR /&gt;
  I note you still have the missing parentheses that I noted in my other forum posting on this subject:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=11428Ⲥ" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=11428Ⲥ&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
  This statement has [pre]&lt;BR /&gt;
302    (SUBSTR(TRIM(LEFT(BRPROV)),1,12) = 'SASKATCHEWAN' AND&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
4 open parens and just 3 close parens. As I said in the previous post, I could not duplicate your error message.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Sun, 11 May 2008 07:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-statment-b/m-p/17113#M2441</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-05-11T07:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: what is the difference between If and Where statment.b</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-statment-b/m-p/17114#M2442</link>
      <description>Don't use the TRIM function.  What you are then returning when BRPROV = 'ALBERTA' is a 7 character value, which is ok for the first SUBSTR but not for the second SUBSTR; 12 is out of range for a 7 character value.</description>
      <pubDate>Mon, 12 May 2008 12:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-statment-b/m-p/17114#M2442</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-12T12:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: what is the difference between If and Where statment.b</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-statment-b/m-p/17115#M2443</link>
      <description>To add my 2 cents SAS has a "starts with" operator =:, So you don't need to coun t the number of positions in a substr function.  For Example:&lt;BR /&gt;
&lt;BR /&gt;
So you could change your if statement from &lt;BR /&gt;
&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' AND&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
to if  BRPROV=:''ALBERTA'' or&lt;BR /&gt;
       BRPROV=:''SASKATCHEWAN' ';&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Of  course ALBERTA and ALBERTAIWYRIAWREIOAW would both be picked up but you should be OK.&lt;BR /&gt;
-Darryl</description>
      <pubDate>Mon, 12 May 2008 12:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-is-the-difference-between-If-and-Where-statment-b/m-p/17115#M2443</guid>
      <dc:creator>darrylovia</dc:creator>
      <dc:date>2008-05-12T12:41:40Z</dc:date>
    </item>
  </channel>
</rss>

