<?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: replace spaces with comma in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replace-spaces-with-comma/m-p/256558#M49175</link>
    <description>&lt;P&gt;That was tricky, thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Mar 2016 14:31:10 GMT</pubDate>
    <dc:creator>ArchanaSudhir</dc:creator>
    <dc:date>2016-03-14T14:31:10Z</dc:date>
    <item>
      <title>replace spaces with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-spaces-with-comma/m-p/256448#M49150</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to replace spaces with comma for a string.&lt;/P&gt;
&lt;P&gt;I have a string var2 with the following value:&lt;/P&gt;
&lt;P&gt;100 20 &amp;nbsp;&amp;nbsp;&amp;nbsp;5 55 (There are 6 spaces after 20)&lt;/P&gt;
&lt;P&gt;Var2 has a length of 128.&lt;/P&gt;
&lt;P&gt;I want to get it as 100,20,5,55(spaces shrinked and a coma in between.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var2=trim(var2);&lt;/P&gt;
&lt;P&gt;var2=compbl(var2);&lt;/P&gt;
&lt;P&gt;var2=tranwrd(var2,"",",");&lt;/P&gt;
&lt;P&gt;I am getting&lt;/P&gt;
&lt;P&gt;100,20,5,55,,,,,,,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise how to remove the trailing commas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Archana&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2016 21:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-spaces-with-comma/m-p/256448#M49150</guid>
      <dc:creator>ArchanaSudhir</dc:creator>
      <dc:date>2016-03-13T21:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: replace spaces with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-spaces-with-comma/m-p/256449#M49151</link>
      <description>&lt;P&gt;You are very close, trim() need to be implemented on the fly, otherwise, if the variable fixed length is larger then the variable contents, the rest of the length will be padded with blanks.&lt;/P&gt;
&lt;P&gt;try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var2=tranwrd(trim(compbl(var2))," ",",");
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Other options including PRXCHANGE, one function does it all:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var_prx=prxchange('s/\s+(?=\S+)/,/',-1 , var2);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Mar 2016 21:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-spaces-with-comma/m-p/256449#M49151</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-03-13T21:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: replace spaces with comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-spaces-with-comma/m-p/256558#M49175</link>
      <description>&lt;P&gt;That was tricky, thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2016 14:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-spaces-with-comma/m-p/256558#M49175</guid>
      <dc:creator>ArchanaSudhir</dc:creator>
      <dc:date>2016-03-14T14:31:10Z</dc:date>
    </item>
  </channel>
</rss>

