<?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: How to use prxchange to replace special characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918912#M361956</link>
    <description>Thanks for your help it works!</description>
    <pubDate>Tue, 05 Mar 2024 00:14:47 GMT</pubDate>
    <dc:creator>Feyng819</dc:creator>
    <dc:date>2024-03-05T00:14:47Z</dc:date>
    <item>
      <title>How to use prxchange to replace special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918861#M361940</link>
      <description>How can I use prxchange to replace special characters like “/,&amp;amp;-“ with space?&lt;BR /&gt;&lt;BR /&gt;For example I have a variable look like “102/103-Apple&amp;amp;Orange” and I want to make it looks “102 103 Apple Orange”, how can I use prxchange to achieve this?&lt;BR /&gt;&lt;BR /&gt;I was trying something like prxchange(‘s/[/-&amp;amp;,]/ /‘,-1, var); but cannot get the variable I want. Thanks for your help in advance!</description>
      <pubDate>Mon, 04 Mar 2024 18:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918861#M361940</guid>
      <dc:creator>Feyng819</dc:creator>
      <dc:date>2024-03-04T18:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use prxchange to replace special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918881#M361942</link>
      <description>&lt;P&gt;for one thing if you want to put '/' in prxchange function, it has to be preceded by '\'. you can try this code.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;&lt;BR /&gt;text='102/103-Apple&amp;amp;Orange,';&lt;BR /&gt;text_new=prxchange('s/[,&amp;amp;\/-]/ /', -1, text);&lt;BR /&gt;proc print;&lt;BR /&gt;run;&amp;nbsp;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Mar 2024 19:44:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918881#M361942</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2024-03-04T19:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use prxchange to replace special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918900#M361949</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/389348"&gt;@Feyng819&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you want to use a heavy tool for a simple task?&amp;nbsp;For replacements of one character by another the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p05ww22zp7lcg3n1bjk7v93tscyo.htm" target="_blank" rel="noopener"&gt;TRANSLATE function&lt;/A&gt; is likely more efficient (and easier to work with) than PRXCHANGE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;31    data _null_;
32    c='102/103-Apple&amp;amp;Orange';
33    c=translate(c, ' ', '/-&amp;amp;');
34    put c;
35    run;

102 103 Apple Orange&lt;/PRE&gt;
&lt;P&gt;The first character in the third argument is replaced by the first character in the second argument (here: a space). In the absence of more characters in the second argument, the remaining characters of the third argument are replaced with spaces by default. (So, even a zero-length string could be used as the second argument because of this default behavior.)&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 21:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918900#M361949</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-03-04T21:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to use prxchange to replace special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918911#M361955</link>
      <description>&lt;P&gt;Also that I agree in principal with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;one possible reason to use a RegEx here could be "laziness" in case you don't know all the characters in advance that you want to replace.&lt;/P&gt;
&lt;P&gt;With RegEx metacharacters in expressions allow you to define whole sets.&lt;/P&gt;
&lt;P&gt;Below code will replace any sequence of characters that aren't letters, digits or an underscore with a single blank.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  text='102/103-Apple&amp;amp;+?Orange,';
  /* ensure variable text_new has same length than text */
  if 0 then text_new=text;
  /* replace any sequence of characters that aren't alphanumeric or underscore with a blank */
  text_new=prxchange('s/\W+/ /', -1, trim(text));
run;

proc print data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2024 00:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918911#M361955</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-03-05T00:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use prxchange to replace special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918912#M361956</link>
      <description>Thanks for your help it works!</description>
      <pubDate>Tue, 05 Mar 2024 00:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918912#M361956</guid>
      <dc:creator>Feyng819</dc:creator>
      <dc:date>2024-03-05T00:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use prxchange to replace special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918913#M361957</link>
      <description>Thanks for your suggestion this is also a way to go:)</description>
      <pubDate>Tue, 05 Mar 2024 00:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918913#M361957</guid>
      <dc:creator>Feyng819</dc:creator>
      <dc:date>2024-03-05T00:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use prxchange to replace special characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918914#M361958</link>
      <description>Thanks for your suggestion:)</description>
      <pubDate>Tue, 05 Mar 2024 00:16:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-prxchange-to-replace-special-characters/m-p/918914#M361958</guid>
      <dc:creator>Feyng819</dc:creator>
      <dc:date>2024-03-05T00:16:06Z</dc:date>
    </item>
  </channel>
</rss>

