<?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 only the second space from a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280122#M269738</link>
    <description>&lt;PRE&gt;
data _null_;
x='xxx yyy zzz';
call scan(x,3,p,l,' ');
want=substr(x,1,p-2)||substr(x,p);
put x= want=;
run;

&lt;/PRE&gt;</description>
    <pubDate>Sat, 25 Jun 2016 08:26:16 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-06-25T08:26:16Z</dc:date>
    <item>
      <title>Remove only the second space from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280054#M269734</link>
      <description>&lt;P&gt;How can I remove only the 2nd space in a string?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 19:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280054#M269734</guid>
      <dc:creator>tropical_surfer</dc:creator>
      <dc:date>2016-06-24T19:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Remove only the second space from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280095#M269735</link>
      <description>&lt;P&gt;There may be easier ways.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may be that this is not what you really want. &amp;nbsp;Remember, you are only shifting text over since the length of a character variable is fixed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may be better served by the COMPBL function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WIth all that in mind, here is a way to approach what you asked for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;set have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;blanks=0;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if string &amp;gt; ' ' then do i=1 to length(string) until (blanks=2);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; if substr(string, i, 1)=' ' then blanks + 1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if blanks=2 then string = substr(string, 1, i-1) || substr(string, i+1);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tried looking at CALL SCAN, but didn't find an approach that seemed like it would work.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 21:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280095#M269735</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-24T21:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Remove only the second space from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280111#M269736</link>
      <description>&lt;P&gt;Given the string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AsBsCssD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where s is a space, do you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AsBCssD &amp;nbsp;(second space of the string removed)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AsBsCsD &amp;nbsp;(double space replaced by single space) ?&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2016 03:27:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280111#M269736</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-25T03:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Remove only the second space from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280112#M269737</link>
      <description>&lt;P&gt;What does "2nd space" mean? The 2nd occurence of a space or just don't have consecutive spaces?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For "not consecutive spaces" I'd use function "compbl()"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2016 04:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280112#M269737</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-06-25T04:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Remove only the second space from a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280122#M269738</link>
      <description>&lt;PRE&gt;
data _null_;
x='xxx yyy zzz';
call scan(x,3,p,l,' ');
want=substr(x,1,p-2)||substr(x,p);
put x= want=;
run;

&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Jun 2016 08:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-only-the-second-space-from-a-string/m-p/280122#M269738</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-25T08:26:16Z</dc:date>
    </item>
  </channel>
</rss>

