<?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: Need a way to identify non-USA keyboard characters in a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/978489#M378608</link>
    <description>&lt;P&gt;Thanks for responding!&lt;BR /&gt;&lt;BR /&gt;The issue I've been running into on z/OS is that despite using the NOTALNUM() function or using&amp;nbsp; PRXMATCH( '/[^a-zA-Z0-9]/','string') to exclude accented characters it treats them as alphanumeic.&amp;nbsp; &amp;nbsp;Really frustraing!&amp;nbsp; I want to flag or show the position of these characters in the variable in the data.&lt;BR /&gt;Any ideas?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Nov 2025 04:13:04 GMT</pubDate>
    <dc:creator>baharvey7817_1</dc:creator>
    <dc:date>2025-11-07T04:13:04Z</dc:date>
    <item>
      <title>Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/956782#M373548</link>
      <description>&lt;P&gt;Hello Community!&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have data that gets aggregated from multiple countries and I need a way to create a flag for a character variable that contains characters that are not found on USA keyboards.&amp;nbsp; Is there a way to do this?&amp;nbsp; &amp;nbsp; Any guidance is appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 18:26:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/956782#M373548</guid>
      <dc:creator>biglerc</dc:creator>
      <dc:date>2025-01-21T18:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/956783#M373549</link>
      <description>&lt;P&gt;Lots of answers here, depending on what "non-USA keyboard characters" really means to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Detect-or-Exclude-rows-which-include-not-standard-ASCII/td-p/886866" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Detect-or-Exclude-rows-which-include-not-standard-ASCII/td-p/886866&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 18:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/956783#M373549</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-01-21T18:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957314#M373719</link>
      <description>&lt;P&gt;Thank you very much for your response!&amp;nbsp; I ended up using a loop through ascii numbers and it worked.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 16:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957314#M373719</guid>
      <dc:creator>biglerc</dc:creator>
      <dc:date>2025-01-27T16:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957384#M373741</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272683"&gt;@biglerc&lt;/a&gt;&amp;nbsp;&amp;nbsp;If you're only dealing with single byte characters then below will also work and requires less code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	var='AbIöIxz'; output;
	var='AbIoIxz'; output;
run;

data want;
	set have;
	nonEnglishChar_flg= prxmatch('/[^a-z]/i',strip(var))&amp;gt;0;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 22:36:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957384#M373741</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2025-01-27T22:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957385#M373742</link>
      <description>&lt;P&gt;Thank you, Patrick!&amp;nbsp; I am dealing with loads of them, since the data is coming from different countries.&amp;nbsp; Here's an example:&amp;nbsp;&amp;nbsp;RESULT = ×ª×©×•×‘×” ×œ×“×•×’×ž×”.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code currently uses substr to go character by character in every text string and identifies the position of a special character (if it finds one).&amp;nbsp; This is working perfectly except for the instances like my example above where the entire string is special characters.&amp;nbsp; In these cases SAS throws an error.&amp;nbsp; Here is my code - it may be too out of context but maybe you can follow it?&amp;nbsp; I'm just wondering why it won't do a substr if the whole value is special characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* step through each character in the field to look for special character(s) */&lt;BR /&gt;do i = 1 to length(current_variable) ;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if rank(substr(current_variable),i,1)) gt 0 and rank(substr(current_variable),i,1)) lt 32 or rank(substr(current_variable),i,1)) gt 127 then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; position= i;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; char = byte(rank(substr(varvalue,i,1)));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nonascii_pos = catx(',',nonascii_pos,strip(put(position,8.)));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nonascii = catx(',',nonascii,strip(char ));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for taking the time to answer my question!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 22:45:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957385#M373742</guid>
      <dc:creator>biglerc</dc:creator>
      <dc:date>2025-01-27T22:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957387#M373743</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272683"&gt;@biglerc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much for your response!&amp;nbsp; I ended up using a loop through ascii numbers and it worked.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No need to loop.&amp;nbsp; You can use COLLATE to generate them.&amp;nbsp; All of the printable characters, from space to tilde, can be generated with COLLATE(32,126). Then use INDEXC() or VERIFY() function depending whether you want to test for the existence of of valid characters or existence of invalid characters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   any_valid = 0 ne indexc(string,collate(32,126));
   any_invalid = 0 ne verify(string,collate(32,126));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input string $50.;
  if string='alpha' then string=tranwrd(string,'alpha','CEB1'x);
cards4;
`1234567890-=~!@#$%^&amp;amp;*()_+
qwertyuiop[]\QWERTYUIOP{}|
asdfghjkl;'ASDFGHJKL:"
zxcvbnm,./ZXCVBNM&amp;lt;&amp;gt;?
alpha
;;;;

data want;
   set have;
   any_valid = 0 ne indexc(trim(string),collate(32,126));
   any_invalid = 0 ne verify(trim(string),collate(32,126));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1738018096702.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104046i795F8F688C8034C7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tom_0-1738018096702.png" alt="Tom_0-1738018096702.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 22:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957387#M373743</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-27T22:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957388#M373744</link>
      <description>&lt;P&gt;This is fantastic! I have never used COLLATE so this is a great learning experience for me.&amp;nbsp; Thank you sooo much!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 22:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957388#M373744</guid>
      <dc:creator>biglerc</dc:creator>
      <dc:date>2025-01-27T22:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957390#M373746</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;
&lt;P&gt;Might I ask you for guidance on a slight modification to the code you sent?&amp;nbsp; Part of my requirement is to keep track of the position of the special character in a string.&amp;nbsp; So for example, if the variable called "RESULT" contains 5 characters and the 3rd character is a special character, then I need to output 1) the name of the variable, 2) the special character(s) and 3) the position(s) of the special character(s).&amp;nbsp; This is why I was looping through each character in the string.&amp;nbsp; My code works correctly if there is at least one NON-special character in the string, however, if all characters are special characters, it crashes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm currently experimenting to see if I can combine my looping with the collate you taught me to resolve this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 23:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957390#M373746</guid>
      <dc:creator>biglerc</dc:creator>
      <dc:date>2025-01-27T23:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957455#M373764</link>
      <description>&lt;P&gt;Looping over the characters in a list should work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might share your issue with the loop failing when there are no special characters in a new topic.&amp;nbsp; Provide a couple of simple example strings that are causing your problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Watch out if you are running with system encoding set to UTF-8 or other multibyte character encodings.&amp;nbsp; It wouldn't matter for generating the simple binary flag variable since the normal 7bit ASCII characters only use one byte.&amp;nbsp; But for locating other characters you will need to use the Kxxxx series of functions that are designed for working with characters that might use more than one byte.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So perhaps something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if verify(string,collate(32,126) then do;
  do i=1 to klength(string);
    length char $4 ;
    char = ksubstr(string,i,1);
    if verify(char,collate(32,126)) then put i= char= ;
  end;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 13:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/957455#M373764</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-28T13:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/978477#M378606</link>
      <description>&lt;P&gt;Will this code work in a mainframe (z/OS) environment?&amp;nbsp; I've tried using the NOTALNUM function but it's interpreting accented characters as alphanumeric anyway.&amp;nbsp; The locale is en_US and the encoding is OPEN_ED-1047.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Nov 2025 21:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/978477#M378606</guid>
      <dc:creator>baharvey7817_1</dc:creator>
      <dc:date>2025-11-06T21:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/978483#M378607</link>
      <description>&lt;P&gt;&lt;SPAN&gt;OPEN_ED-1047 is a Single Byte encoding.&amp;nbsp; So you don't need to worry about multi-byte characters or using KSUBSTR().&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can use KCVT() to convert the ASCII string generated by COLLATE into the equivalent OPEN_ED-10247 string.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  do i=1 to length(string);
    char = char(string,i);
    if verify(char,kcvt(collate(32,126),'latin1','OPEN_ED-1047')) then do;
      put i= char= $hex2. ;
    end;
  end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Nov 2025 21:45:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/978483#M378607</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-11-06T21:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/978489#M378608</link>
      <description>&lt;P&gt;Thanks for responding!&lt;BR /&gt;&lt;BR /&gt;The issue I've been running into on z/OS is that despite using the NOTALNUM() function or using&amp;nbsp; PRXMATCH( '/[^a-zA-Z0-9]/','string') to exclude accented characters it treats them as alphanumeic.&amp;nbsp; &amp;nbsp;Really frustraing!&amp;nbsp; I want to flag or show the position of these characters in the variable in the data.&lt;BR /&gt;Any ideas?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Nov 2025 04:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/978489#M378608</guid>
      <dc:creator>baharvey7817_1</dc:creator>
      <dc:date>2025-11-07T04:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need a way to identify non-USA keyboard characters in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/978493#M378610</link>
      <description>You could also try to use COMPRESS().&lt;BR /&gt;&lt;BR /&gt;x=compress(string,,'kad');&lt;BR /&gt;&lt;BR /&gt;If x is not missing ,there are some characters you want to look for.</description>
      <pubDate>Fri, 07 Nov 2025 06:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-a-way-to-identify-non-USA-keyboard-characters-in-a-string/m-p/978493#M378610</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-11-07T06:21:03Z</dc:date>
    </item>
  </channel>
</rss>

