<?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: How to look for a list of values in a character variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271498#M54012</link>
    <description>&lt;P&gt;Try to use the &lt;STRONG&gt;contains&lt;/STRONG&gt; clause in SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where store_name contains keyword&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 May 2016 18:20:54 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-05-18T18:20:54Z</dc:date>
    <item>
      <title>How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271475#M54005</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a character string where that contains the names of various stores and I would like to filter the observations based on certain store values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried substring function but it does not work all the time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is an example of what I am looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Store_names&lt;/P&gt;
&lt;P&gt;ABC STORE&lt;/P&gt;
&lt;P&gt;APPLE COMPUTERS&lt;/P&gt;
&lt;P&gt;MICROSOFT CORPORATION&lt;/P&gt;
&lt;P&gt;COSTCO STORE&lt;/P&gt;
&lt;P&gt;WALMART&lt;/P&gt;
&lt;P&gt;SAMS CLUB&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired Output file&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Store_names&lt;/P&gt;
&lt;P&gt;ABC STORE&lt;/P&gt;
&lt;P&gt;COSTCO&lt;/P&gt;
&lt;P&gt;APPLE COMPUTERS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 17:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271475#M54005</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-05-18T17:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271491#M54009</link>
      <description>&lt;P&gt;So you want to search but not for exact values?&lt;/P&gt;
&lt;P&gt;I'm not sure what you need beyond the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
where store_name in ('ABC STORE' 'COSTCO STORE' 'APPLE COMUTERS');
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 17:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271491#M54009</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-18T17:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271494#M54011</link>
      <description>&lt;P&gt;Thanks Reeza!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;yes, I am not searching for the exact values.&lt;/P&gt;
&lt;P&gt;for eg: I need to find APPLE COMPUTERS in the desired output file with a filter of 'APPLE'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested the where conditon but it did not work.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 17:57:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271494#M54011</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-05-18T17:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271498#M54012</link>
      <description>&lt;P&gt;Try to use the &lt;STRONG&gt;contains&lt;/STRONG&gt; clause in SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where store_name contains keyword&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 18:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271498#M54012</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-05-18T18:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271500#M54013</link>
      <description>&lt;P&gt;Thanks PG Stats!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Contians works but only with one value. It does not work in my test, where I checked for a list of values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eg: where store_name in ('COSTCO') &amp;nbsp;works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; but not ('COSTCO', 'APPLE', 'SAMS') - does not support I think.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 18:29:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271500#M54013</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-05-18T18:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271502#M54014</link>
      <description>&lt;P&gt;Unfortunately all of the Contains/Find/Index functions all work with a single argument.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ie contains ("APPLE") or contains ("COMPUTERS") or contains("COSTCO")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have your list in a dataset?&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 18:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271502#M54014</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-18T18:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271506#M54015</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No, my list is hardcoded.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 18:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271506#M54015</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-05-18T18:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271518#M54019</link>
      <description>&lt;P&gt;Here's an example using an array to loop through your words.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input stores $32.;
cards;
ABC STORE
APPLE COMPUTERS
MICROSOFT CORPORATION
COSTCO STORE
WALMART
SAMS CLUB
;
run;

data want;
array lookup(2) $ _temporary_  ("COSTCO" "APPLE" );

set have;
do i=1 to dim(lookup);
if find(stores, trim(lookup(i)))&amp;gt;0 then output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 May 2016 19:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271518#M54019</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-18T19:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271519#M54020</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 19:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271519#M54020</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-05-18T19:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271567#M54027</link>
      <description>&lt;P&gt;Reeza should use FINDW() .&lt;/P&gt;
&lt;P&gt;Here is an alternative way .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input stores $32.;
cards;
ABC STORE
APPLE COMPUTERS
MICROSOFT CORPORATION
COSTCO STORE
WALMART
SAMS CLUB
;
run;

data want;
set have;
if prxmatch('/\b(COSTCO|APPLE|ABC)\b/i',stores);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 May 2016 01:22:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271567#M54027</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-05-19T01:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271571#M54029</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;, add suffix letter 'o' so that the matching pattern is compiled only once :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'/\b(COSTCO|APPLE|ABC)\b/io'&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2016 01:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271571#M54029</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-05-19T01:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to look for a list of values in a character variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271742#M54062</link>
      <description>&lt;P&gt;Thanks Ksharp, PGStats!&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2016 15:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-look-for-a-list-of-values-in-a-character-variable/m-p/271742#M54062</guid>
      <dc:creator>renjithr</dc:creator>
      <dc:date>2016-05-19T15:14:36Z</dc:date>
    </item>
  </channel>
</rss>

