<?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 to remove space or special char in string? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692396#M210930</link>
    <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;I am trying to remove space inside strings, e.g. remove the space before "1" in the string "XXX-1234. 1". I have many values in the same format i.e. "XXX-####.#". Many of them have space after the "." and before the last digit. I would like to remove any space in the strings. Some of them can be removed successfully by using compress(). But some of them, the space cannot be removed by compress().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if the space was from some special char or something else than typing. How can I identify and remove them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Sun, 18 Oct 2020 20:29:24 GMT</pubDate>
    <dc:creator>sasecn</dc:creator>
    <dc:date>2020-10-18T20:29:24Z</dc:date>
    <item>
      <title>How to remove space or special char in string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692396#M210930</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;I am trying to remove space inside strings, e.g. remove the space before "1" in the string "XXX-1234. 1". I have many values in the same format i.e. "XXX-####.#". Many of them have space after the "." and before the last digit. I would like to remove any space in the strings. Some of them can be removed successfully by using compress(). But some of them, the space cannot be removed by compress().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if the space was from some special char or something else than typing. How can I identify and remove them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2020 20:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692396#M210930</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2020-10-18T20:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove space or special char in string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692398#M210932</link>
      <description>&lt;P&gt;Spaces are not necessarily blanks, so there's an option within the COMPRESS functions to handle multiple different types of spaces, it's the third example in the documentation. That adding in that modifier (third parameter) and see if it works for you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
   x='1 2 3 4 5';
   y=compress(x, , 's');
   put y=;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0fcshr0ir3h73n1b845c4aq58hz.htm&amp;amp;locale=en#p1sxqxvyibtfkvn19it2hysrrkre"&gt;https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0fcshr0ir3h73n1b845c4aq58hz.htm&amp;amp;locale=en#p1sxqxvyibtfkvn19it2hysrrkre&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/84484"&gt;@sasecn&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;I am trying to remove space inside strings, e.g. remove the space before "1" in the string "XXX-1234. 1". I have many values in the same format i.e. "XXX-####.#". Many of them have space after the "." and before the last digit. I would like to remove any space in the strings. Some of them can be removed successfully by using compress(). But some of them, the space cannot be removed by compress().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure if the space was from some special char or something else than typing. How can I identify and remove them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2020 20:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692398#M210932</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-18T20:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove space or special char in string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692400#M210934</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;I tried this and that doesn't work. What confused me is that why the compress() works on some values, but not all of them. My data was imported from excel file. I am thinking if there is anything wired in the format or the space was caused by special char ...&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2020 20:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692400#M210934</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2020-10-18T20:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove space or special char in string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692410#M210938</link>
      <description>&lt;P&gt;Next code tells compress function which characters to keep,&lt;/P&gt;
&lt;P&gt;a=alpha, d=digits, p=punctuation, k=keep:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_var = compress(var, ,'kadp');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;try it and adapt to your needs.&lt;/P&gt;
&lt;P&gt;More characters in the link posted by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2020 23:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692410#M210938</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-10-18T23:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove space or special char in string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692565#M210998</link>
      <description>&lt;P&gt;Yes, the options of keep chars needed worked in my situation. I also found another way to delete the non-breaking space from excel by using compress(var, 'A0'x). But your solution is best to keep chars needed.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 13:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692565#M210998</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2020-10-19T13:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove space or special char in string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692568#M210999</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84484"&gt;@sasecn&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply.&lt;/P&gt;
&lt;P&gt;I tried this and that doesn't work. What confused me is that why the compress() works on some values, but not all of them. My data was&lt;STRONG&gt; imported from excel &lt;/STRONG&gt;file. I am thinking if there is anything wired in the format or the space was caused by special char ...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If by "imported" you mean that you use Proc Import or one of the wizards that can be a significant factor. Some of the characters involved could be the vertical spaces that Excel uses when data is entered with the Alt-Enter, or actual end of line characters if such were in data that is written to Excel from a data base.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 14:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692568#M210999</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-19T14:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove space or special char in string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692575#M211002</link>
      <description>&lt;P&gt;I used the import wizard from SAS EG to import the excel file. I did check the source excel file, and find many spaces caused by typo, tab, alt+enter ... The excel file was created by other users, so I cannot exam one by one of them. The compress() with options can fix the problem,&amp;nbsp; hopefully fixed all the problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you mentioned that different import may have different results, wondering if there is such a way to import the excel&amp;nbsp; that can eliminate&amp;nbsp; the problems (unexpected space at the beginning, between and end of strings, special chars ...) at the beginning?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 14:16:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-space-or-special-char-in-string/m-p/692575#M211002</guid>
      <dc:creator>sasecn</dc:creator>
      <dc:date>2020-10-19T14:16:47Z</dc:date>
    </item>
  </channel>
</rss>

