<?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 Conditional statement with wild cards in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592453#M169876</link>
    <description>&lt;P&gt;I got errors with the following IF/Then statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if POSTAL_CODE like "T__" and AREA_CODE in ("368", "403", "587", "780", "825") then
	PROVINCE="AB";&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class="sasError focus-line"&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Does that mean I cannot use wild cards in the conditional statement? What code should I put to check if the first char of the string is 'T' ?&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Sun, 29 Sep 2019 03:50:34 GMT</pubDate>
    <dc:creator>MLAC</dc:creator>
    <dc:date>2019-09-29T03:50:34Z</dc:date>
    <item>
      <title>Conditional statement with wild cards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592453#M169876</link>
      <description>&lt;P&gt;I got errors with the following IF/Then statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if POSTAL_CODE like "T__" and AREA_CODE in ("368", "403", "587", "780", "825") then
	PROVINCE="AB";&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class="sasError focus-line"&gt;ERROR 388-185: Expecting an arithmetic operator.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Does that mean I cannot use wild cards in the conditional statement? What code should I put to check if the first char of the string is 'T' ?&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 29 Sep 2019 03:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592453#M169876</guid>
      <dc:creator>MLAC</dc:creator>
      <dc:date>2019-09-29T03:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement with wild cards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592457#M169877</link>
      <description>&lt;P&gt;The LIKE operator is not available in the DATA step, except as a WHERE condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you can do something like (no pun intended):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if POSTAL_CODE =: 'T' and AREA_CODE in ("368", "403", "587", "780", "825") then PROVINCE="AB";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the &lt;EM&gt;&lt;STRONG&gt;=:&lt;/STRONG&gt;&lt;/EM&gt; relation take the shorter of the two expressions and sees if the other expression starts with matching characters.&amp;nbsp; In this case it test whether postal_code starts with a 'T',&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Sep 2019 04:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592457#M169877</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-09-29T04:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement with wild cards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592458#M169878</link>
      <description>&lt;P&gt;The LIKE operator is not valid within an IF condition.&amp;nbsp;&lt;A href="http://support.sas.com/kb/43/303.html" target="_self"&gt;Here&lt;/A&gt;&amp;nbsp;what you can use instead.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Sep 2019 04:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592458#M169878</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-09-29T04:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement with wild cards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592465#M169879</link>
      <description>&lt;P&gt;Thanks. That helps. But the output of the second part on that page is wrong.&amp;nbsp; The output should like this:&lt;/P&gt;&lt;P&gt;Diana&lt;BR /&gt;Diane&lt;BR /&gt;DIANNA&lt;/P&gt;</description>
      <pubDate>Sun, 29 Sep 2019 04:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592465#M169879</guid>
      <dc:creator>MLAC</dc:creator>
      <dc:date>2019-09-29T04:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional statement with wild cards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592745#M169985</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292818"&gt;@MLAC&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks. That helps. But the output of the second part on that page is wrong.&amp;nbsp; The output should like this:&lt;/P&gt;
&lt;P&gt;Diana&lt;BR /&gt;Diane&lt;BR /&gt;DIANNA&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Example data of the input to get that output and the actual code you used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If referring to the example link that &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;showed then I submit that you really show the code that you ran as that is the exact result I get with the data. Note that depending on what you did it may be that your code modified the input set because unfortunately the example code is using the&lt;/P&gt;
&lt;PRE&gt;data test;
   set test;&lt;/PRE&gt;
&lt;P&gt;construct repeatedly. And each one completely rewrites the set Test. So if you played around with the code for the first example, such as the &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;   /* the syntax to select observations that /*
   /*  do not match the pattern is below */
   *if name not =: 'D';
&lt;/PRE&gt;
&lt;P&gt;then you may have removed the values that are expected for the second part.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 16:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-statement-with-wild-cards/m-p/592745#M169985</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-30T16:11:31Z</dc:date>
    </item>
  </channel>
</rss>

