<?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: Identify and remove hidden characters in character variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721099#M223427</link>
    <description>&lt;P&gt;Try removing the formats first and see if it solved the issue. &lt;BR /&gt;I think you need to add the K option if you're using the ad option which would remove all numeric and alphabetic characters. I suggested the s modifier to remove white space. &lt;BR /&gt;&lt;BR /&gt;The HEX format, shows you the values as hex code. So 2F, A0, 20 are all different white space characters. &lt;BR /&gt;2F - /&lt;BR /&gt;20 - space&lt;BR /&gt;A0 is a white space that's likely causing part of your issue. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
set have;
all_managers = compress(all_managers, , 's');
run;

proc freq data=temp;
tables all_managers;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Feb 2021 22:00:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-02-22T22:00:31Z</dc:date>
    <item>
      <title>Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721080#M223417</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I imported an excel spreadsheet and one of the variables seems to have some extra characters of some sort. It is a character variable called "Deviation" and the responses are "YES", "NO", and "N/A", yet it thinks I have two "NO" groups and two "YES" groups when I do a frequency table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;deviation &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;frequency&lt;/P&gt;&lt;P&gt;N/A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 639&lt;/P&gt;&lt;P&gt;YES &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;/P&gt;&lt;P&gt;YES &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;NO &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;524&lt;/P&gt;&lt;P&gt;NO &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;32&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;Deviation &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Frequency&lt;/P&gt;&lt;P&gt;N/A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 639&lt;/P&gt;&lt;P&gt;YES &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 21&lt;/P&gt;&lt;P&gt;NO &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;556&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 21:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721080#M223417</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2021-02-22T21:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721085#M223419</link>
      <description>COMPRESS with the s modifier&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0fcshr0ir3h73n1b845c4aq58hz.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0fcshr0ir3h73n1b845c4aq58hz.htm&amp;amp;locale=en&lt;/A&gt;</description>
      <pubDate>Mon, 22 Feb 2021 21:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721085#M223419</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-22T21:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721086#M223420</link>
      <description>&lt;P&gt;It helps to look at the output using the regular old plan text LISTING destination instead of some graphically complex ODS destination.&lt;/P&gt;
&lt;P&gt;You can try using the $QUOTE. format to help see the leading spaces.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the $HEX. format to see what characters are actually in the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most likely you have leading spaces. ('20'X)&amp;nbsp; You might have trailing linefeeds ('0A'x).&amp;nbsp; It is possible you have some non-breaking spaces ('A0'x) on either side.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 21:47:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721086#M223420</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-22T21:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721090#M223421</link>
      <description>I'm not sure what the Quote and HEX formats are....</description>
      <pubDate>Mon, 22 Feb 2021 21:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721090#M223421</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2021-02-22T21:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721096#M223425</link>
      <description>&lt;P&gt;I used the following code and got this&lt;/P&gt;&lt;P&gt;data temp;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;all_managers = compress(all_managers, , 'ad');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc freq data=temp;&lt;/P&gt;&lt;P&gt;tables all_managers;&lt;/P&gt;&lt;P&gt;format all_managers $hex30.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Deviation &amp;nbsp; &amp;nbsp; &amp;nbsp;FREQUENCY&lt;/P&gt;&lt;P&gt;2F202020 &amp;nbsp; &amp;nbsp; &amp;nbsp; 639&lt;/P&gt;&lt;P&gt;A0202020 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 33&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what this means....&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 21:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721096#M223425</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2021-02-22T21:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721098#M223426</link>
      <description>I did that and nothing happened...</description>
      <pubDate>Mon, 22 Feb 2021 21:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721098#M223426</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2021-02-22T21:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721099#M223427</link>
      <description>&lt;P&gt;Try removing the formats first and see if it solved the issue. &lt;BR /&gt;I think you need to add the K option if you're using the ad option which would remove all numeric and alphabetic characters. I suggested the s modifier to remove white space. &lt;BR /&gt;&lt;BR /&gt;The HEX format, shows you the values as hex code. So 2F, A0, 20 are all different white space characters. &lt;BR /&gt;2F - /&lt;BR /&gt;20 - space&lt;BR /&gt;A0 is a white space that's likely causing part of your issue. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
set have;
all_managers = compress(all_managers, , 's');
run;

proc freq data=temp;
tables all_managers;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 22:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721099#M223427</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-22T22:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721102#M223430</link>
      <description>I tried what you posted (Reeza) and nothing changed...</description>
      <pubDate>Mon, 22 Feb 2021 22:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721102#M223430</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2021-02-22T22:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721103#M223431</link>
      <description>&lt;P&gt;You will need to check the meaning of those COMPRESS() function options in the documentation.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.google.com/search?q=%40sas.com+compress()+function" target="_blank"&gt;https://www.google.com/search?q=%40sas.com+compress()+function&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 2F on your first line is just the slash character, /&lt;/P&gt;
&lt;P&gt;But the A0 in your last row is the dreaded non-breaking space (or at least that is what Microsoft has decided to use that particular non-printing character to mean and lot of other software has adopted it.).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See what happens if you just remove the non-breaking space.&amp;nbsp; While you are at in remove any leading spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is code to remove the non-breaking spaces, left align (aka remove leading spaces) and also generate hex codes for the first 10 characters.&amp;nbsp; Then run PROC FREQ and show both the text and the hexcode version on the same line so it is easier to see what letter the hex codes represent.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
  set have;
  all_managers = left(compress(all_managers,'A0'x));
  hex=put(all_managers,$hex20.);
run;

proc freq data=temp;
  tables all_managers*hex / list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 22:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721103#M223431</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-22T22:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721104#M223432</link>
      <description>Then you need to be able to post an example of your data so we can replicate the issue.</description>
      <pubDate>Mon, 22 Feb 2021 22:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721104#M223432</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-22T22:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and remove hidden characters in character variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721106#M223434</link>
      <description>Thank you! That worked!!!</description>
      <pubDate>Mon, 22 Feb 2021 22:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-remove-hidden-characters-in-character-variable/m-p/721106#M223434</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2021-02-22T22:09:22Z</dc:date>
    </item>
  </channel>
</rss>

