<?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 How do you search a string of characters for a variable? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900191#M40109</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, the Subject wasn't clear. So, what I am trying to do is, I have a variable with values like the following:&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; exampleVar&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; dog&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;cat&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp;apple&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to return a list of IDs if the variable contains any of the following values, ('o', 'g', 'e'). So the result should be 1 and 3. I thought of verify function and prxmatch, but I couldn't quite come up with a solution with them. Is manual search the only solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Oct 2023 18:52:47 GMT</pubDate>
    <dc:creator>cosmid</dc:creator>
    <dc:date>2023-10-26T18:52:47Z</dc:date>
    <item>
      <title>How do you search a string of characters for a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900191#M40109</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, the Subject wasn't clear. So, what I am trying to do is, I have a variable with values like the following:&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; exampleVar&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; dog&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;cat&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp;apple&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to return a list of IDs if the variable contains any of the following values, ('o', 'g', 'e'). So the result should be 1 and 3. I thought of verify function and prxmatch, but I couldn't quite come up with a solution with them. Is manual search the only solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 18:52:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900191#M40109</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2023-10-26T18:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a string of characters for a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900195#M40111</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    if find(examplevar,'o') or find(examplevar,'g') or find(examplevar,'e') then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm going to guess this doesn't work on your real problem, even though it does work on your made-up problem. So, please tell us the real problem you are trying to solve.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 19:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900195#M40111</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-26T19:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a string of characters for a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900242#M40118</link>
      <description>Thanks for the find function. To answer your question, the real problem is:&lt;BR /&gt;There is this variable with foreign characters, something like àäèéëïĳöü The objective is to list out all of the observations with at least one of these characters. However, the actual list is about 30+ characters, so I can write 30+ find () or. As I am writing this reply, I just realized I may be able to use the verify function and just pick out observations with normal alphanumerics.</description>
      <pubDate>Thu, 26 Oct 2023 22:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900242#M40118</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2023-10-26T22:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a string of characters for a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900243#M40119</link>
      <description>&lt;P&gt;I think that you may want to look at the KINDEXC or KINDEXB (if using a double-byte character set).&lt;/P&gt;
&lt;PRE&gt;data example;
   x='This value contains an é in the middle.';
   y=kindexc(x,'àäèéëïĳöü');
run;&lt;/PRE&gt;
&lt;P&gt;Kindexc searches the first parameter, the source, for any of the characters in the second and returns the first position that one of them is found&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OR if the next step is replace those letters with something more English looking skip straight to the Translate function:&lt;/P&gt;
&lt;PRE&gt;data example2;
   x='à ä è é ë ï ĳ ö ü';
   y=translate(x,'aAeEeiIou','àäèéëïĳöü');
run;&lt;/PRE&gt;
&lt;P&gt;Translate uses the characters in position order of the second parameter to replace those found in the third position. Note: be very careful to align them. I used changing case for the repetitive ones just as an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 22:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900243#M40119</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-26T22:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a string of characters for a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900259#M40124</link>
      <description>&lt;P&gt;VERIFY does the opposite test from what you describe.&amp;nbsp; It is used to find the first occurrence of character that is NOT in the list.&amp;nbsp; Instead you want the INDEXC() function (or if the case does not matter perhaps the FINDC() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where indexc(examplevar,'dog');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But in your later comments you mention non-ASCII characters.&amp;nbsp; If you are not using a single byte encoding then you will need to use Kindexc() instead.&amp;nbsp; That is because INDEXC() will treat each byte of the multiple byte characters as something to find and you will get a lot of false positive results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 01:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900259#M40124</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-27T01:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a string of characters for a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900299#M40125</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253026"&gt;@cosmid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks for the find function. To answer your question, the real problem is:&lt;BR /&gt;There is this variable with foreign characters, something like àäèéëïĳöü The objective is to list out all of the observations with at least one of these characters. However, the actual list is about 30+ characters, so I can write 30+ find () or. As I am writing this reply, I just realized I may be able to use the verify function and just pick out observations with normal alphanumerics.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Always helpful to start by telling us the real problem, rather than a fake problem that is different from the real problem in important ways&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 10:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900299#M40125</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-27T10:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do you search a string of characters for a variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900312#M40126</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*The best choice is using Perl Regular Expression*/
data have;
input ID     exampleVar $;
cards;
1       dog
2      cat
3      apple
;
option noquotelenmax;
data want;
 set have;
 if prxmatch('/o|g|e/i',exampleVar);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Oct 2023 11:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-you-search-a-string-of-characters-for-a-variable/m-p/900312#M40126</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-10-27T11:37:35Z</dc:date>
    </item>
  </channel>
</rss>

