<?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 unwanted character from a character string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-character-from-a-character-string/m-p/312833#M67878</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my data, the following values are present. I am not &amp;nbsp;getting the output I need with my code. Please help. Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;value&lt;/P&gt;&lt;P&gt;ALLEGRA-D /01367401/&lt;/P&gt;&lt;P&gt;AMOXICILLIN W/CLAVULANATE POTASSIUM&lt;/P&gt;&lt;P&gt;ASCORBIC ACID W/BETACAROTENE/BIOTIN/08634701/&lt;BR /&gt;BUDESONIDE W/FORMOTEROL FUMARATE&lt;BR /&gt;ESOMEPRAZOLE MAGNESIUM&lt;BR /&gt;HYDROCODONE COMPOUND /01224801/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output needed;&lt;/P&gt;&lt;P&gt;ALLEGRA-D&amp;nbsp;&lt;/P&gt;&lt;P&gt;AMOXICILLIN W/CLAVULANATE POTASSIUM&lt;/P&gt;&lt;P&gt;ASCORBIC ACID W/BETACAROTENE/BIOTIN&lt;BR /&gt;BUDESONIDE W/FORMOTEROL FUMARATE&lt;BR /&gt;ESOMEPRAZOLE MAGNESIUM&lt;BR /&gt;HYDROCODONE COMPOUND&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;value1=compress(value,'','d');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output getting;&lt;/P&gt;&lt;P&gt;ALLEGRA-D//&lt;/P&gt;&lt;P&gt;AMOXICILLINW/CLAVULANATE POTASSIUM&lt;/P&gt;&lt;P&gt;ASCORBICACID W/BETACAROTENE/BIOTIN//&lt;BR /&gt;BUDESONIDEW/FORMOTEROLFUMARATE&lt;BR /&gt;ESOMEPRAZOLEMAGNESIUM&lt;BR /&gt;HYDROCODONECOMPOUND//&lt;/P&gt;</description>
    <pubDate>Sat, 19 Nov 2016 22:37:07 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2016-11-19T22:37:07Z</dc:date>
    <item>
      <title>How to remove unwanted character from a character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-character-from-a-character-string/m-p/312833#M67878</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my data, the following values are present. I am not &amp;nbsp;getting the output I need with my code. Please help. Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;value&lt;/P&gt;&lt;P&gt;ALLEGRA-D /01367401/&lt;/P&gt;&lt;P&gt;AMOXICILLIN W/CLAVULANATE POTASSIUM&lt;/P&gt;&lt;P&gt;ASCORBIC ACID W/BETACAROTENE/BIOTIN/08634701/&lt;BR /&gt;BUDESONIDE W/FORMOTEROL FUMARATE&lt;BR /&gt;ESOMEPRAZOLE MAGNESIUM&lt;BR /&gt;HYDROCODONE COMPOUND /01224801/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output needed;&lt;/P&gt;&lt;P&gt;ALLEGRA-D&amp;nbsp;&lt;/P&gt;&lt;P&gt;AMOXICILLIN W/CLAVULANATE POTASSIUM&lt;/P&gt;&lt;P&gt;ASCORBIC ACID W/BETACAROTENE/BIOTIN&lt;BR /&gt;BUDESONIDE W/FORMOTEROL FUMARATE&lt;BR /&gt;ESOMEPRAZOLE MAGNESIUM&lt;BR /&gt;HYDROCODONE COMPOUND&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;value1=compress(value,'','d');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output getting;&lt;/P&gt;&lt;P&gt;ALLEGRA-D//&lt;/P&gt;&lt;P&gt;AMOXICILLINW/CLAVULANATE POTASSIUM&lt;/P&gt;&lt;P&gt;ASCORBICACID W/BETACAROTENE/BIOTIN//&lt;BR /&gt;BUDESONIDEW/FORMOTEROLFUMARATE&lt;BR /&gt;ESOMEPRAZOLEMAGNESIUM&lt;BR /&gt;HYDROCODONECOMPOUND//&lt;/P&gt;</description>
      <pubDate>Sat, 19 Nov 2016 22:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-character-from-a-character-string/m-p/312833#M67878</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2016-11-19T22:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove unwanted character from a character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-character-from-a-character-string/m-p/312836#M67880</link>
      <description>&lt;P&gt;Assuming the pattern you need to remove is at the end of the string and looks like &amp;nbsp;&lt;EM&gt;/&amp;lt;at least one digit&amp;gt;/&lt;/EM&gt; then the following should do the job.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  infile datalines truncover;
  length have_str want_str $60;
  input have_str $60.;
  want_str=prxchange('s/\/\d+\/\s*$//oi',1,have_str);
  datalines;
ALLEGRA-D /01367401/
AMOXICILLIN W/CLAVULANATE POTASSIUM
ASCORBIC ACID W/BETACAROTENE/BIOTIN/08634701/
BUDESONIDE W/FORMOTEROL FUMARATE
ESOMEPRAZOLE MAGNESIUM
HYDROCODONE COMPOUND /01224801/
;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Nov 2016 23:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-character-from-a-character-string/m-p/312836#M67880</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-19T23:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove unwanted character from a character string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-character-from-a-character-string/m-p/312855#M67889</link>
      <description>&lt;P&gt;You're halfway there.&amp;nbsp; You removed all the digits, but you still have an unwanted pair '//'.&amp;nbsp; Use the TRANSTRN function to eliminate those.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  value1=compress(value,'','d');
  value1=transtrn(value1,'//','');

  /* or  value1=transtrn(compress(value,,'d'),'//','');  */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course your program assumes the only time you have digits is when they occupy every character&amp;nbsp;between a pair of slashes.&amp;nbsp; You don't expect numerals anywhere else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a more specific rule.&amp;nbsp; If value ends with a pair of slashes encompasing digits, remove it all.&amp;nbsp;&amp;nbsp; This would leave other digits in place:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=lastchar lastword);
  set have;
  lastchar=substr(value,length(value),1);
  if lastchar='/' then do;
    lastword=scan(value,-2,'/');
    if notdigit(trim(lastword))=0 then value1=transtrn(value,cats('/',lastword,'/'),'');
  end;
  else value1=value;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Sun, 20 Nov 2016 01:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-unwanted-character-from-a-character-string/m-p/312855#M67889</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-11-20T01:57:47Z</dc:date>
    </item>
  </channel>
</rss>

