<?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: wildcard % in if statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366791#M87264</link>
    <description>&lt;P&gt;With just a handful of cities, it's easy to construct this sort of program;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if index(city, 'TORONTO') then city='TORONTO';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With hundreds of cities, we might want to look at how to automate constructing so many IF/THEN/ELSE statements.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jun 2017 23:27:05 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-06-13T23:27:05Z</dc:date>
    <item>
      <title>wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366785#M87261</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a&amp;nbsp;dataset with 1000's of accounts and most have a field of Canadian cities and some are inputted with wonky characters before and after, for example TORONTO could have 56TORONTO or 37TORONTO sddre56 or 93f MONTREA 8d , etc.. endless combination.&amp;nbsp; I want to be able to say if it contains TORONTO in the field then change the value to TORONTO, etc.&amp;nbsp; I can do this in either proc sql or data statement.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:13:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366785#M87261</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2017-06-13T23:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366789#M87262</link>
      <description>&lt;P&gt;in proc dql&lt;/P&gt;
&lt;P&gt;case when columnname like '%TORONTO% then TORONTO else '' end as newcolumn&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for datastep use below example picked from SAS website&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if find(name,'Toronto','i') ge 1 then newcolumn=';
   /* equivalent WHERE clause */
   *where upcase(name) contains 'TORONTO';&lt;/PRE&gt;
&lt;P&gt;For this kind, best option is to put all your values in a reference table and use it.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366789#M87262</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-13T23:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366790#M87263</link>
      <description>&lt;P&gt;FINDW or INDEXW&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366790#M87263</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-13T23:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366791#M87264</link>
      <description>&lt;P&gt;With just a handful of cities, it's easy to construct this sort of program;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if index(city, 'TORONTO') then city='TORONTO';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With hundreds of cities, we might want to look at how to automate constructing so many IF/THEN/ELSE statements.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366791#M87264</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-13T23:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366792#M87265</link>
      <description>&lt;P&gt;Try the INDEX function &amp;nbsp;- if INDEX(address, 'TORONTO') &amp;gt; 0&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:29:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366792#M87265</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-06-13T23:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366793#M87266</link>
      <description>&lt;P&gt;How many values do you have to search for?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A brief data step example with if&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if index(upcase(city),'TORONTO')&amp;gt;0 then City='Toronto';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your example showing MONTREA&amp;nbsp; is going to have issues if that is supposed to match MONTREAL though.&lt;/P&gt;
&lt;P&gt;If there is a clean postal code it may be easier to match on that value if you have a set with city and postal code available anywhere.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366793#M87266</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-13T23:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366794#M87267</link>
      <description>&lt;P&gt;From your examples next code may give you partial solution&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
  set have;
        city = compress(city_in, '0123456789');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but that code is not a solution forh "&lt;SPAN&gt;93f MONTREA 8d".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You need analyze more issues to add other treatment.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366794#M87267</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-06-13T23:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366795#M87268</link>
      <description>&lt;P&gt;of the many ways suggested this is another&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;
&amp;nbsp;&amp;nbsp; if prxmatch('m/TORONTO/',var)&amp;gt;0 then City='Toronto';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366795#M87268</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-06-13T23:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366797#M87269</link>
      <description>&lt;P&gt;Thanks everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What if I have more than 1 city that I&amp;nbsp;want to be considered in TORONTO?&amp;nbsp; for example 54ETOBICOKE57 and 839TORONTO9827 then CITY = GTA, etc...&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366797#M87269</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2017-06-13T23:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366798#M87270</link>
      <description>&lt;P&gt;You need come up with what is your match, otherwise wildcard can take many values, sometimes you may not be aware of.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366798#M87270</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-13T23:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366800#M87271</link>
      <description>&lt;P&gt;&lt;SPAN&gt;case when columnname like '%TOronto89% or &amp;nbsp;columnname like '%TOwhatever% then TORONTO else '' end as newcolumn. just added when more or condition&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366800#M87271</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-13T23:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: wildcard % in if statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366801#M87272</link>
      <description>&lt;P&gt;Then you put them all in a master list - use a master list of cities from your province&amp;nbsp;- and use SOUNDEX/LIKE or COMPGED functions to calculate distance and correct the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe there are address cleaning routines on Lexjansen.com for Canada specifically.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 23:42:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/wildcard-in-if-statement/m-p/366801#M87272</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-13T23:42:28Z</dc:date>
    </item>
  </channel>
</rss>

