<?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 do I separate a string of numbers with commas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-separate-a-string-of-numbers-with-commas/m-p/499410#M132891</link>
    <description>&lt;P&gt;I have a string of the following numbers which I would like to separate with commas.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;000100002000300040005&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0001,0002,0003,0004,0005&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I do not at any point know the length of the string.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Sep 2018 09:15:20 GMT</pubDate>
    <dc:creator>Sir_Lancelot</dc:creator>
    <dc:date>2018-09-27T09:15:20Z</dc:date>
    <item>
      <title>How do I separate a string of numbers with commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-separate-a-string-of-numbers-with-commas/m-p/499410#M132891</link>
      <description>&lt;P&gt;I have a string of the following numbers which I would like to separate with commas.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;000100002000300040005&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0001,0002,0003,0004,0005&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I do not at any point know the length of the string.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 09:15:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-separate-a-string-of-numbers-with-commas/m-p/499410#M132891</guid>
      <dc:creator>Sir_Lancelot</dc:creator>
      <dc:date>2018-09-27T09:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate a string of numbers with commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-separate-a-string-of-numbers-with-commas/m-p/499411#M132892</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;i = 1;
do while (i &amp;lt; length(invar));
  outvar = catx(',',outvar,substr(invar,i,4));
  i + 4;
end;
drop i;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Sep 2018 09:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-separate-a-string-of-numbers-with-commas/m-p/499411#M132892</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-27T09:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate a string of numbers with commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-separate-a-string-of-numbers-with-commas/m-p/499413#M132894</link>
      <description>&lt;P&gt;Are they always four characters?&amp;nbsp; If not how do you know where one starts and one stops?&lt;/P&gt;
&lt;P&gt;If they are always four then:&lt;/P&gt;
&lt;PRE&gt;data want;
  str="000100002000300040005";
  length new_str $200;
  do i=0 to lengthn(str)/4;
    new_str=catx(",",new_str,substr(str,(i*4)+1,4));
  end;
run;&lt;/PRE&gt;
&lt;P&gt;However that doesn't get your output as 00002 is not four.&amp;nbsp; You need to have some logical base to split the string.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 09:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-separate-a-string-of-numbers-with-commas/m-p/499413#M132894</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-27T09:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I separate a string of numbers with commas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-separate-a-string-of-numbers-with-commas/m-p/499490#M132925</link>
      <description>&lt;P&gt;Just for fun.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
x='00010002000300040005';
length want $ 200;
do i=1 to length(x);
 if mod(i,4)=1 then want=catx(',',want,char(x,i)); 
  else want=cats(want,char(x,i));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Sep 2018 13:01:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-separate-a-string-of-numbers-with-commas/m-p/499490#M132925</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-09-27T13:01:18Z</dc:date>
    </item>
  </channel>
</rss>

