<?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: Removing special character from a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-special-character-from-a-string/m-p/832250#M328936</link>
    <description>&lt;P&gt;If you just have two standard patterns, namely (where 9 represents any sequence of digits).&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&amp;gt;99,999(xxxx)&lt;BR /&gt;&amp;nbsp; and&lt;/LI&gt;
&lt;LI&gt;999&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;then in the case of the first pattern you can scan for the 1st "word" starting at position 2, where "word" is a string that terminates at the separator "(".&amp;nbsp; For the second pattern it's just a straight copy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input string $20.;
datalines;
&amp;gt;10,000(3/29)
256
run;

data want;
  set have;
  if string=: '&amp;gt;' then x=scan(substr(string,2),1,'(');
  else x=string;
  put (_all_) (=);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note the&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  =:&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;comparison operator compares two strings, truncating the longer string to the length of the shorter string.&amp;nbsp; So the comparison tests whether the string starts with a "&amp;gt;".&lt;/P&gt;</description>
    <pubDate>Thu, 08 Sep 2022 13:49:53 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2022-09-08T13:49:53Z</dc:date>
    <item>
      <title>Removing special character from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-special-character-from-a-string/m-p/832248#M328934</link>
      <description>&lt;P&gt;Hi, I'm having some problem removing special characters in my dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For values "&amp;gt;10,000(3/29), how do I just extract "10,000" for those values?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried :&lt;/P&gt;&lt;P&gt;initial_dimer=prxchange('s/\(([^\)]+)\)//i', -1, initial_dimer),&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it just removes the whole thing and leaves it blank.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-09-07 at 4.22.34 PM.png" style="width: 123px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75058i6B09730941864E6C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-09-07 at 4.22.34 PM.png" alt="Screen Shot 2022-09-07 at 4.22.34 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated! Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 20:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-special-character-from-a-string/m-p/832248#M328934</guid>
      <dc:creator>stevenyan0127</dc:creator>
      <dc:date>2022-09-07T20:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Removing special character from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-special-character-from-a-string/m-p/832250#M328936</link>
      <description>&lt;P&gt;If you just have two standard patterns, namely (where 9 represents any sequence of digits).&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&amp;gt;99,999(xxxx)&lt;BR /&gt;&amp;nbsp; and&lt;/LI&gt;
&lt;LI&gt;999&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;then in the case of the first pattern you can scan for the 1st "word" starting at position 2, where "word" is a string that terminates at the separator "(".&amp;nbsp; For the second pattern it's just a straight copy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input string $20.;
datalines;
&amp;gt;10,000(3/29)
256
run;

data want;
  set have;
  if string=: '&amp;gt;' then x=scan(substr(string,2),1,'(');
  else x=string;
  put (_all_) (=);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note the&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  =:&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;comparison operator compares two strings, truncating the longer string to the length of the shorter string.&amp;nbsp; So the comparison tests whether the string starts with a "&amp;gt;".&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 13:49:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-special-character-from-a-string/m-p/832250#M328936</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-09-08T13:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Removing special character from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-special-character-from-a-string/m-p/832271#M328945</link>
      <description>&lt;P&gt;and here a regex that should work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input string $20.;
datalines;
&amp;gt;10,000(3/29)
256
run;

data want;
  set have;
  string=prxchange('s/^[^\d]*(\d[\d,]*).*$/$1/i', -1, strip(string));
  put string=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Sep 2022 05:53:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-special-character-from-a-string/m-p/832271#M328945</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-09-08T05:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Removing special character from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-special-character-from-a-string/m-p/832291#M328955</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input string $20.;
want=scan(string,1,',.','kd');
datalines;
&amp;gt;10,000(3/29)
256
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Sep 2022 11:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-special-character-from-a-string/m-p/832291#M328955</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-09-08T11:10:05Z</dc:date>
    </item>
  </channel>
</rss>

