<?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: Remove the 2nd special character in a cell in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-the-2nd-special-character-in-a-cell/m-p/738853#M230533</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Have $;
cards;
6.9.	6.9
7.8.	7.8
6.2.	6.2
8.9.2	8.92
4.5.2	4.52
6.5.7
;
data want;
 set have;
 call scan(have,-1,p,l,'.');
 want=cats(substr(have,1,l-1),substrn(have,p));
 drop p l;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 May 2021 11:03:35 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-05-04T11:03:35Z</dc:date>
    <item>
      <title>Remove the 2nd special character in a cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-the-2nd-special-character-in-a-cell/m-p/738833#M230523</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset with a column of year in values. Most of the values are incorrect while enter the data.&lt;/P&gt;
&lt;P&gt;Here I attach the sample dataset along with expected output.&lt;/P&gt;
&lt;TABLE width="105"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="53"&gt;&lt;STRONG&gt;Have&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="52"&gt;&lt;STRONG&gt;Want&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6.9.&lt;/TD&gt;
&lt;TD&gt;6.9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;7.8.&lt;/TD&gt;
&lt;TD&gt;7.8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6.2.&lt;/TD&gt;
&lt;TD&gt;6.2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8.9.2&lt;/TD&gt;
&lt;TD&gt;8.92&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4.5.2&lt;/TD&gt;
&lt;TD&gt;4.52&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6.5.7&lt;/TD&gt;
&lt;TD&gt;6.57&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;Kindly suggest a code to get the given output.&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 10:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-the-2nd-special-character-in-a-cell/m-p/738833#M230523</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2021-05-04T10:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Remove the 2nd special character in a cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-the-2nd-special-character-in-a-cell/m-p/738850#M230531</link>
      <description>&lt;P&gt;The function "notdigit": Searches a character string for any character that is not a digit, and returns the first position at which that character is found. The function has a second parameter allowing to select from which position search is started. So you could loop until notdigit returns 0, using cats and substr to remove the unwanted content. Some easier solution are possible, but i don't know enough about the data you have: the second step assumes, that the special char to keep is always the dot and that ^ is never part of the string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want_a;
   set have;
   
   want = have;
   s = notdigit(want);
   put s=;
   
   do while (s &amp;gt; 0);
      s = notdigit(trim(want), s+1);
     
      if s &amp;gt; 0 then do;
         want = cats(substr(want, 1, s-1), substr(want, s+1));
      end;
   end;
run;


data want_b;
   set have;
   
   want = have;
   substr(want, notdigit(want), 1) = '^';
   want = compress(want, '^', 'kd');
   want = translate(want, '.', '^');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 10:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-the-2nd-special-character-in-a-cell/m-p/738850#M230531</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-05-04T10:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Remove the 2nd special character in a cell</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-the-2nd-special-character-in-a-cell/m-p/738853#M230533</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Have $;
cards;
6.9.	6.9
7.8.	7.8
6.2.	6.2
8.9.2	8.92
4.5.2	4.52
6.5.7
;
data want;
 set have;
 call scan(have,-1,p,l,'.');
 want=cats(substr(have,1,l-1),substrn(have,p));
 drop p l;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 May 2021 11:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-the-2nd-special-character-in-a-cell/m-p/738853#M230533</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-04T11:03:35Z</dc:date>
    </item>
  </channel>
</rss>

