<?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 statements with wildcard characters in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/IF-statements-with-wildcard-characters/m-p/252971#M254</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I am just starting out using SAS. I have been doing some basic data manipulation and cannot seem to find a how-to on using the wildcard function with IF statements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I wrote;&lt;/P&gt;&lt;P&gt;data work.cars;&lt;BR /&gt;set work.cars;&lt;BR /&gt;if displ=&amp;gt;0 and City_MPG=&amp;gt;30 and model^="*hydrid*" then Eff='Yes';&lt;BR /&gt;if Model='%Hybrid%' then Eff='Hyb';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am simply trying to weed out any vehicle models that have Hybrid (non-case sensitive if possible) in their name from my Eff(icient) column. What have I done incorrectly? It isn't giving me errors, but the Hybrid vehicles are not changing to "Hyb", they are just saying "Yes" from my previous IF statement.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Sat, 27 Feb 2016 22:05:46 GMT</pubDate>
    <dc:creator>wy2sl0</dc:creator>
    <dc:date>2016-02-27T22:05:46Z</dc:date>
    <item>
      <title>IF statements with wildcard characters</title>
      <link>https://communities.sas.com/t5/SAS-Studio/IF-statements-with-wildcard-characters/m-p/252971#M254</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I am just starting out using SAS. I have been doing some basic data manipulation and cannot seem to find a how-to on using the wildcard function with IF statements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I wrote;&lt;/P&gt;&lt;P&gt;data work.cars;&lt;BR /&gt;set work.cars;&lt;BR /&gt;if displ=&amp;gt;0 and City_MPG=&amp;gt;30 and model^="*hydrid*" then Eff='Yes';&lt;BR /&gt;if Model='%Hybrid%' then Eff='Hyb';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am simply trying to weed out any vehicle models that have Hybrid (non-case sensitive if possible) in their name from my Eff(icient) column. What have I done incorrectly? It isn't giving me errors, but the Hybrid vehicles are not changing to "Hyb", they are just saying "Yes" from my previous IF statement.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 27 Feb 2016 22:05:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/IF-statements-with-wildcard-characters/m-p/252971#M254</guid>
      <dc:creator>wy2sl0</dc:creator>
      <dc:date>2016-02-27T22:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: IF statements with wildcard characters</title>
      <link>https://communities.sas.com/t5/SAS-Studio/IF-statements-with-wildcard-characters/m-p/252974#M255</link>
      <description>&lt;P&gt;use index function for that&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(LOWCASE(model),'hybrid') then ....&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 27 Feb 2016 22:43:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/IF-statements-with-wildcard-characters/m-p/252974#M255</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-27T22:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: IF statements with wildcard characters</title>
      <link>https://communities.sas.com/t5/SAS-Studio/IF-statements-with-wildcard-characters/m-p/252976#M256</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/75266"&gt;@wy2sl0﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In string comparisons in the DATA step those "wildcard" characters&amp;nbsp;have no special meaning. They are treated as ordinary characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="http://support.sas.com/documentation/cdl/en/syntaxidx/68719/HTML/default/index.htm#/documentation/cdl/en/sqlproc/69049/HTML/default/n1ege2983n6h0vn1s1uj1459phr9.htm" target="_blank"&gt;LIKE condition&lt;/A&gt; in PROC SQL, however, uses the percent sign and the underscore (not the asterisk) as wildcard characters. But I haven't seen or used this very often, because there are other tools available, e.g. character functions such as the INDEX function suggested by mohamed_zaki.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case you should avoid typos such as "hy&lt;U&gt;d&lt;/U&gt;rid" when coding string comparisons. (Or did you really mean "hydrid"?)&lt;/P&gt;</description>
      <pubDate>Sat, 27 Feb 2016 23:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/IF-statements-with-wildcard-characters/m-p/252976#M256</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-27T23:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: IF statements with wildcard characters</title>
      <link>https://communities.sas.com/t5/SAS-Studio/IF-statements-with-wildcard-characters/m-p/252977#M257</link>
      <description>&lt;P&gt;Total mistake! I am going to try the advice given after dinner thanks you two.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;EDIT: It worked perfectly! Thanks so much! This is a very important IF statement I will need to use. Appreciate it!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2016 00:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/IF-statements-with-wildcard-characters/m-p/252977#M257</guid>
      <dc:creator>wy2sl0</dc:creator>
      <dc:date>2016-02-28T00:04:08Z</dc:date>
    </item>
  </channel>
</rss>

