<?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: Single Character Wildcards in find function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431962#M106906</link>
    <description>This is absolutely perfect. Thank you so much!!</description>
    <pubDate>Mon, 29 Jan 2018 20:42:24 GMT</pubDate>
    <dc:creator>jeanderson</dc:creator>
    <dc:date>2018-01-29T20:42:24Z</dc:date>
    <item>
      <title>Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431926#M106888</link>
      <description>&lt;P&gt;In a data step (Base SAS 9.4), I am trying to parse my good data from my bad data. One condition of good data is that var4 contains a string that starts with H then is followed by 4 integers and a comma. Other text may be before or after this 6-character string.&lt;/P&gt;&lt;P&gt;Examples:&lt;/P&gt;&lt;P&gt;Good data:&amp;nbsp;H2009, V7WK48&lt;/P&gt;&lt;P&gt;Bad data:&amp;nbsp;HV2030, V5WK24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code I thought would work:&lt;/P&gt;&lt;P&gt;data test2 wonkydata;&lt;BR /&gt;set test;&lt;/P&gt;&lt;P&gt;if find(var4,'%H____,%')=0 then output wonkydata; /*Remove data in wrong format for extracting ID*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;However, both good and bad data are being output to wonkydata.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my first time posting a question here, so if I need to provide more info please let me know. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 19:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431926#M106888</guid>
      <dc:creator>jeanderson</dc:creator>
      <dc:date>2018-01-29T19:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431932#M106891</link>
      <description>&lt;P&gt;best approach is use regular expressions (&lt;STRONG&gt;PRX&lt;/STRONG&gt;) pattern functions than find for your case. PRX syntax hurts my eyes/sinuses but I am sure somebody else will help you shortly with the syntax. Hang in there!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 19:53:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431932#M106891</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-29T19:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431934#M106892</link>
      <description>&lt;P&gt;% isn't a wildcard in the FIND statement, that works in SQL or WHERE statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your best bet is PRX or a regular expression but I find those difficult.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I usually use CHAR() instead with a loop and like in this question:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/48469465/check-specific-sequence-of-alphanumeric-string-in-sas/48470612#48470612" target="_blank"&gt;https://stackoverflow.com/questions/48469465/check-specific-sequence-of-alphanumeric-string-in-sas/48470612#48470612&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/189940"&gt;@jeanderson&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;In a data step (Base SAS 9.4), I am trying to parse my good data from my bad data. One condition of good data is that var4 contains a string that starts with H then is followed by 4 integers and a comma. Other text may be before or after this 6-character string.&lt;/P&gt;
&lt;P&gt;Examples:&lt;/P&gt;
&lt;P&gt;Good data:&amp;nbsp;H2009, V7WK48&lt;/P&gt;
&lt;P&gt;Bad data:&amp;nbsp;HV2030, V5WK24&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code I thought would work:&lt;/P&gt;
&lt;P&gt;data test2 wonkydata;&lt;BR /&gt;set test;&lt;/P&gt;
&lt;P&gt;if find(var4,'%H____,%')=0 then output wonkydata; /*Remove data in wrong format for extracting ID*/&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;However, both good and bad data are being output to wonkydata.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my first time posting a question here, so if I need to provide more info please let me know. Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 19:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431934#M106892</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-29T19:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431941#M106896</link>
      <description>&lt;P&gt;PRX functions are great ... but there is a learning curve.&amp;nbsp; Here's a way that uses simple enough tools that&amp;nbsp; you probably already have used before:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2 wonkydata;&lt;/P&gt;
&lt;P&gt;set test;&lt;/P&gt;
&lt;P&gt;if var4 =: 'H' and substr(var4, 6, 1) = ',' and (1000 &amp;lt;= input(substr(var4, 2, 4), ?? 4.) &amp;lt;= 9999) then output test2;&lt;/P&gt;
&lt;P&gt;else output wonkydata;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But what does it mean when you say that VAR4 begins with these character, yet there can be other text before or after this string?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431941#M106896</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-29T20:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431948#M106897</link>
      <description>&lt;P&gt;I meant that the condition I need to parse on begins with H and is followed by 4 integers and a comma, but the data is so inconsistent that I can't rely on it being the first characters in the field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I may be able to use your solution&amp;nbsp;but will have to add something to allow the H____, to start at any point in the string.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431948#M106897</guid>
      <dc:creator>jeanderson</dc:creator>
      <dc:date>2018-01-29T20:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431949#M106898</link>
      <description>&lt;P&gt;Regular expressions aren't that difficult, if you can bend your mind in some or another way &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	
	isGood = prxmatch('/.*H\d{4,4},.*/', trim(var4));
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;Expressions start and end with slash.&lt;/LI&gt;&lt;LI&gt;.* matches any char, 0 to n-times&lt;/LI&gt;&lt;LI&gt;\d matches a digit, {4,4} matches four digits&lt;/LI&gt;&lt;LI&gt;, the comma after the digit&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431949#M106898</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-01-29T20:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431950#M106899</link>
      <description>&lt;P&gt;This sounds perfect. Is there any way I can use it in an if statement? If it fails, what does it return?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:25:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431950#M106899</guid>
      <dc:creator>jeanderson</dc:creator>
      <dc:date>2018-01-29T20:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431951#M106900</link>
      <description>&lt;P&gt;While my code could be modified to look for the first "H" and perform the same inspection, that might not be enough.&amp;nbsp; You might have multiple sections of your string that begin with "H".&amp;nbsp; Since you have a sample PRX solution, I would go that route instead ... assuming you test it and find it is working for all the cases:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;H at the beginning&lt;/P&gt;
&lt;P&gt;H in the middle&lt;/P&gt;
&lt;P&gt;multiple words that begin with H (especially when the first one is wonky but the second one is good)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;********** EDITED:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;One more thing to consider:&amp;nbsp; If "H" begins the last word within the text, will there be a comma after it?&amp;nbsp; Will the proposed solution work when there is no comma at the end of the line?&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431951#M106900</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-29T20:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431954#M106901</link>
      <description>&lt;P&gt;From the documentation: "Searches for a pattern match and returns the position at which the pattern is found." If the string is not found 0 is returned.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 20:28:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431954#M106901</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-01-29T20:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431961#M106905</link>
      <description>Without the comma, it would be missing other data I need to extract from the field and would be wonky anyway.</description>
      <pubDate>Mon, 29 Jan 2018 20:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431961#M106905</guid>
      <dc:creator>jeanderson</dc:creator>
      <dc:date>2018-01-29T20:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Single Character Wildcards in find function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431962#M106906</link>
      <description>This is absolutely perfect. Thank you so much!!</description>
      <pubDate>Mon, 29 Jan 2018 20:42:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Single-Character-Wildcards-in-find-function/m-p/431962#M106906</guid>
      <dc:creator>jeanderson</dc:creator>
      <dc:date>2018-01-29T20:42:24Z</dc:date>
    </item>
  </channel>
</rss>

