<?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 Searching a string for a list of words in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212899#M39322</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm having troubles figuring out what function I should use to search a string variable for a number of words, any help greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table of website descriptions&lt;/P&gt;&lt;P&gt;ID SiteDesc&lt;/P&gt;&lt;P&gt;1 acura car dealer&lt;/P&gt;&lt;P&gt;2 acura used car dealer&lt;/P&gt;&lt;P&gt;3 toyota deals&lt;/P&gt;&lt;P&gt;4 deals for acura&lt;/P&gt;&lt;P&gt;5 chevy car sales&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For records 1-4 i'd like to create a category variable with value of "Import"&lt;/P&gt;&lt;P&gt;For record 5, the category would be "domestic"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a list of 10 manufacturers for each category, i'm not sure what the best way to create this classification by looping through the string for each manufacturer?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 May 2015 11:52:44 GMT</pubDate>
    <dc:creator>DangIT</dc:creator>
    <dc:date>2015-05-11T11:52:44Z</dc:date>
    <item>
      <title>Searching a string for a list of words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212899#M39322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm having troubles figuring out what function I should use to search a string variable for a number of words, any help greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table of website descriptions&lt;/P&gt;&lt;P&gt;ID SiteDesc&lt;/P&gt;&lt;P&gt;1 acura car dealer&lt;/P&gt;&lt;P&gt;2 acura used car dealer&lt;/P&gt;&lt;P&gt;3 toyota deals&lt;/P&gt;&lt;P&gt;4 deals for acura&lt;/P&gt;&lt;P&gt;5 chevy car sales&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For records 1-4 i'd like to create a category variable with value of "Import"&lt;/P&gt;&lt;P&gt;For record 5, the category would be "domestic"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a list of 10 manufacturers for each category, i'm not sure what the best way to create this classification by looping through the string for each manufacturer?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 11:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212899#M39322</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-05-11T11:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a string for a list of words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212900#M39323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is your logic ? How do you define it as "Import" or as "domestic" ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 11:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212900#M39323</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-11T11:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a string for a list of words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212901#M39324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a list of manufacturers for each category.&lt;/P&gt;&lt;P&gt;For example:&lt;BR /&gt;For Import, if any of the following: acura, toyota, hyundai, kia, honda, etc.&lt;/P&gt;&lt;P&gt;For Domestic, if any of the following: ford, chevy, mercury, gm, jeep, pontiac etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 12:12:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212901#M39324</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-05-11T12:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a string for a list of words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212902#M39325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, you could do something like the below.&amp;nbsp; It makes several assumptions though, car is not in import and domestic for example.&amp;nbsp; E.g. what happens for:&lt;/P&gt;&lt;P&gt;acura and chevy car dealer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;data list;&lt;/P&gt;&lt;P&gt;&amp;nbsp; type="Domestic";&lt;/P&gt;&lt;P&gt;&amp;nbsp; word="acura"; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; word="toyota"; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; type="Import";&lt;/P&gt;&lt;P&gt;&amp;nbsp; word="chevy"; output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length type $20;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id=1; text="acura car dealer"; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id=2; text="acura used car dealer"; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id=3; text="toyota deals"; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id=4; text="deals for acura"; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id=5; text="chevy car sales"; output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; update HAVE A&lt;/P&gt;&lt;P&gt;&amp;nbsp; set TYPE=(select distinct TYPE from LIST where index(lowcase(A.TEXT),lowcase(WORD))&amp;gt;0);&amp;nbsp; /* Note you could also do by merge */&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 12:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212902#M39325</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-11T12:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a string for a list of words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212903#M39326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good for PRX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;
data have;
&amp;nbsp; length text $20;
&amp;nbsp; id=1; text="acura car dealer"; output;
&amp;nbsp; id=2; text="acura used car dealer"; output;
&amp;nbsp; id=3; text="toyota deals"; output;
&amp;nbsp; id=4; text="deals for acura"; output;
&amp;nbsp; id=5; text="chevy car sales"; output;
run;
data want;
 set have;
 length type $20;
 if prxmatch('/acura|toyota|hyundai|kia|honda/i',text) then type='Import';
&amp;nbsp; else if prxmatch('/ford|chevy|mercury|gm|jeep|pontiac/i',text) then type='Domestic';
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 12:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-a-string-for-a-list-of-words/m-p/212903#M39326</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-11T12:45:36Z</dc:date>
    </item>
  </channel>
</rss>

