<?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 Replace special char by 1 space in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762315#M241344</link>
    <description>&lt;P&gt;Currently, I am facing special characters issue, how shall I replace these special char with 1 space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data cm0_;&lt;BR /&gt;cmtrt = "Metforminã€€Hydrochlorideã€€Tablets"; output;&lt;BR /&gt;cmtrt = "Newdatarequired";output;&lt;BR /&gt;cmtrt = "";output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Requirement:&amp;nbsp;Metformin Hydrochloride Tablets&lt;/P&gt;</description>
    <pubDate>Wed, 18 Aug 2021 15:37:45 GMT</pubDate>
    <dc:creator>pdhokriya</dc:creator>
    <dc:date>2021-08-18T15:37:45Z</dc:date>
    <item>
      <title>Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762315#M241344</link>
      <description>&lt;P&gt;Currently, I am facing special characters issue, how shall I replace these special char with 1 space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data cm0_;&lt;BR /&gt;cmtrt = "Metforminã€€Hydrochlorideã€€Tablets"; output;&lt;BR /&gt;cmtrt = "Newdatarequired";output;&lt;BR /&gt;cmtrt = "";output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Requirement:&amp;nbsp;Metformin Hydrochloride Tablets&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 15:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762315#M241344</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2021-08-18T15:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762321#M241348</link>
      <description>&lt;P&gt;Is that the only pattern in your dataset? If so, this works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set cm0_;
		cmtrt_2 = tranwrd(cmtrt, "ã€€", " ");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;cmtrt 	                                                cmtrt_2
Metforminã€€Hydrochlorideã€€Tablets 	Metformin Hydrochloride Tablets
Newdatarequired 	                                Newdatarequired
  	 &lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Aug 2021 15:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762321#M241348</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-08-18T15:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762325#M241351</link>
      <description>&lt;P&gt;Typically I just replace the strange things with spaces and then use COMPBL() to collapse the multiple spaces.&lt;/P&gt;
&lt;P&gt;What do you consider "special"?&lt;/P&gt;
&lt;P&gt;Perhaps anything that is not between a space and a tilde?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
cmtrt = "Metforminã€€Hydrochlorideã€€Tablets"; 
want = compbl(translate(cmtrt,' ',collate(0,31)||collate(127,255)));
put (_all_) (=/);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 16:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762325#M241351</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-18T16:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762337#M241356</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/55374"&gt;@pdhokriya&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works for your example in a SAS session using WLATIN1 encoding&amp;nbsp; ...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set cm0_;
cmtrt=kpropdata(cmtrt,' ','utf-8');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;... and suggests that the '&lt;SPAN&gt;ã€€' string originally was a UTF-8&lt;/SPAN&gt;&amp;nbsp;character of some sort. Therefore, the same solution&amp;nbsp;&lt;EM&gt;might&lt;/EM&gt; work for other "unprintable" UTF-8 characters as well. You can specify &lt;FONT face="courier new,courier"&gt;'wlatin1'&lt;/FONT&gt; explicitly as the fourth argument if needed (see&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/nlsref/n0p2w5303sepamn1rctpdkngr4tc.htm" target="_blank" rel="noopener"&gt;documentation of the KPROPDATA function&lt;/A&gt;).&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 16:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762337#M241356</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-08-18T16:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762437#M241419</link>
      <description>&lt;P&gt;Hi, No this is hardcoding, I have other special chars also.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 03:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762437#M241419</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2021-08-19T03:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762439#M241421</link>
      <description>&lt;P&gt;This is working:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data test; cmtrt = "Metforminã€€Hydrochlorideã€€Tablets"; want = compbl(translate(cmtrt,' ',collate(127,255))); put (_all_) (=/); run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to know more about this: what is happening when 0,31 and 127,255 considered?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;collate(0,31)||collate(127,255)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 03:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762439#M241421</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2021-08-19T03:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762441#M241423</link>
      <description>Hi , Thank you for reply, this does not work.</description>
      <pubDate>Thu, 19 Aug 2021 03:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762441#M241423</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2021-08-19T03:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762448#M241425</link>
      <description>&lt;P&gt;In a single byte encoding there are only 256 possible codes from 0 to 255.&amp;nbsp;The &lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lefunctionsref/n1k9dtbhesk4lgn1dwbj5xfudwft.htm" target="_self"&gt;COLLATE() function&lt;/A&gt; just makes it easy to generate a series of characters by there code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://www.ascii-code.com/" target="_self"&gt;ASCII code&lt;/A&gt; for a space is 32.&amp;nbsp; Any byte less than that is a control character, like a tab or a linefeed.&lt;/P&gt;
&lt;P&gt;The ASCII code for a tilde is 126.&amp;nbsp; 127 is a DELETE character.&amp;nbsp; Anything from 128 to 255 has the 8th bit and so is not part of the normal 7-bit ASCII codes.&amp;nbsp; That is where all of the accented characters and other strange glyphs live.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 04:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762448#M241425</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-19T04:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762485#M241446</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/55374"&gt;@pdhokriya&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi , Thank you for reply, this does not work.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What happened when you tried it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See how it works on my workstation:&lt;/P&gt;
&lt;PRE&gt;1    proc options option=encoding;
2    run;

    SAS (r) Proprietary Software Release 9.4  TS1M5

 ENCODING=WLATIN1  Specifies the default character-set encoding for the SAS session.
NOTE: PROCEDURE OPTIONS used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


3
4    data cm0_;
5    cmtrt = "Metforminã€€Hydrochlorideã€€Tablets"; output;
6    cmtrt = "Newdatarequired";output;
7    cmtrt = "";output;
8    run;

NOTE: The data set WORK.CM0_ has 3 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds


9
10   data want;
11   set cm0_;
12   cmtrt=kpropdata(cmtrt,' ','utf-8');
13   run;

NOTE: There were 3 observations read from the data set WORK.CM0_.
NOTE: The data set WORK.WANT has 3 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


14
15   proc print data=want;
16   run;

NOTE: There were 3 observations read from the data set WORK.WANT.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


17
18   proc print data=want;
19   format cmtrt $hex70.;
20   run;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;Obs    cmtrt

 1     Metformin Hydrochloride Tablets
 2     Newdatarequired
 3&lt;/FONT&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;Obs    cmtrt

 1     4D6574666F726D696E&lt;U&gt;&lt;STRONG&gt;20&lt;/STRONG&gt;&lt;/U&gt;487964726F63686C6F72696465&lt;U&gt;&lt;STRONG&gt;20&lt;/STRONG&gt;&lt;/U&gt;5461626C65747320202020
 2     4E65776461746172657175697265642020202020202020202020202020202020202020
 3     2020202020202020202020202020202020202020202020202020202020202020202020&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;The two '20'x characters highlighted above in obs. 1 are the blanks that replaced the original 3-byte UTF-8 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Meanwhile I found out that '&lt;SPAN&gt;ã€€' = 'E38080'x is indeed a space character in UTF-8, called "ideographic space" (code point U+3000) and used in the context of Chinese, Japanese and Korean languages.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;References:&amp;nbsp;&lt;A href="https://unicode.org/charts/nameslist/n_3000.html" target="_blank"&gt;https://unicode.org/charts/nameslist/n_3000.html&lt;/A&gt;&amp;nbsp;and (for the conversion between code points like U+3000 and hexadecimal UTF-8 codes like E38080)&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/UTF-8" target="_blank"&gt;https://en.wikipedia.org/wiki/UTF-8&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 08:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762485#M241446</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-08-19T08:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762494#M241448</link>
      <description>&lt;P&gt;Another way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data T;
  OLD = "Metforminã€€Hydrochlorideã€€Tablets";
  NEW = compbl(prxchange('s/[^a-zA-Z]/ /',-1,OLD));
  put (_ALL_) (=/);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;OLD=Metforminã€€Hydrochlorideã€€Tablets&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;NEW=Metformin Hydrochloride Tablets&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Note that&amp;nbsp;ã€€ is&amp;nbsp;UTF-8&amp;nbsp;for&amp;nbsp;&lt;A href="https://codepoints.net/U+3000?lang=en" target="_self"&gt;IDEOGRAPHIC SPACE&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;When reading an UTF-8 string, you should use &lt;A href="https://www.pharmasug.org/proceedings/2016/BB/PharmaSUG-2016-BB15.pdf" target="_self"&gt;UTF-8 encoding&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 10:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/762494#M241448</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-08-19T10:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replace special char by 1 space</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/763812#M241907</link>
      <description>THank you for ur input</description>
      <pubDate>Wed, 25 Aug 2021 11:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-special-char-by-1-space/m-p/763812#M241907</guid>
      <dc:creator>pdhokriya</dc:creator>
      <dc:date>2021-08-25T11:07:33Z</dc:date>
    </item>
  </channel>
</rss>

