<?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 Characters From Unformated String in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347845#M273349</link>
    <description>&lt;P&gt;You can look at the SCAN() function as well. The modifiers will help.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Apr 2017 17:19:48 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-04-06T17:19:48Z</dc:date>
    <item>
      <title>Removing Characters From Unformated String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347837#M273347</link>
      <description>&lt;P&gt;Hello! I am trying to remove certain characters from unformated strings. What I mean by "unformated" is these variables have discrepancies so that a simple compress or substr&amp;nbsp;won't work (or at least I don't think they would).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following column from an xlsx file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here's what they look like&lt;/STRONG&gt; ........ &lt;STRONG&gt;and here's what I'm interested in&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1X4F--0754 ................................. 0754&lt;/P&gt;&lt;P&gt;1X4F-0016 .................................. 0016&lt;/P&gt;&lt;P&gt;1X4F-0023 .................................. 0023&lt;/P&gt;&lt;P&gt;1X4F-2008-01 ............................. 2008&lt;/P&gt;&lt;P&gt;1X4F-2008-02 ............................. ^&lt;/P&gt;&lt;P&gt;1X4F-330 .................................... 3300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that the first value had double dashes. This was entered manually and is a mistake. Also note that 2008-01 and 2008-02 are the same and should be one value. The last value is incomplete.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way for me to reshape this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;Yawen&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 17:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347837#M273347</guid>
      <dc:creator>yawenyu</dc:creator>
      <dc:date>2017-04-06T17:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters From Unformated String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347843#M273348</link>
      <description>&lt;P&gt;The double dashes can be dealt with via prxchange. The duplicate values could be dealt with with nodupkey sort, but it would depend on the rest of your data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input str :$12.;
str2 = scan(prxchange('s/--/-/', -1, str), 2, '-');
datalines;
1X4F--0754
1X4F-0016
1X4F-0023
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Apr 2017 17:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347843#M273348</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-06T17:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters From Unformated String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347845#M273349</link>
      <description>&lt;P&gt;You can look at the SCAN() function as well. The modifiers will help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 17:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347845#M273349</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-06T17:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters From Unformated String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347849#M273350</link>
      <description>&lt;P&gt;This may get you started:&lt;/P&gt;
&lt;PRE&gt;data example;
   infile datalines truncover;
   informat x $13.;
   input x;
   length y $ 4;
   y= scan(x,2,'-',);
datalines;
1X4F--0754
1X4F-0016
1X4F-0023 
1X4F-2008-01 
1X4F-2008-02
1X4F-330 
;
run;&lt;/PRE&gt;
&lt;P&gt;If the "incomplete" is always handled the same way you could add a test for&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if length(y) &amp;lt; 4 then y=catt(y,'0'); if the action needed is to always place a 0 at the end. But that was not specified by your request, you just said is was incomplete.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 17:33:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347849#M273350</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-06T17:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Characters From Unformated String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347928#M273351</link>
      <description>&lt;P&gt;You guys were all correct to suggest the&amp;nbsp;scan function! It totally fixed my problem. Thank you all!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 20:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Characters-From-Unformated-String/m-p/347928#M273351</guid>
      <dc:creator>yawenyu</dc:creator>
      <dc:date>2017-04-06T20:49:51Z</dc:date>
    </item>
  </channel>
</rss>

