<?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: Turning one row into multiple rows based on length in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/411850#M100687</link>
    <description>&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data have;
  id=1; number="65747 736356 837364 837336"; output;
  id=2; number="556773 6738373 8373839 677838"; output;
run;

data want (drop=i number);
  set have;
  number=compress(number);
  length want $4.;
  do i=1 to lengthn(number);
    want=cats(want,char(number,i));
    if mod(i,4)=0 then do;
      output;
      want="";
    end;
  end;
run;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Nov 2017 10:06:07 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-11-09T10:06:07Z</dc:date>
    <item>
      <title>Turning one row into multiple rows based on length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/411843#M100683</link>
      <description>Hello everyone!&lt;BR /&gt;I have a data with a row of phone numbers like this:&lt;BR /&gt;&lt;BR /&gt;Name  number&lt;BR /&gt;id1     65747 736356 837364 837336&lt;BR /&gt;id2     556773 6738373 8373839 677838&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;I want number column to have length equal to 4. &lt;BR /&gt;Name number&lt;BR /&gt;id1  6574&lt;BR /&gt;Id1  7736&lt;BR /&gt;Id1  3568&lt;BR /&gt;And so on &lt;BR /&gt;&lt;BR /&gt;Any help will be appreciated.</description>
      <pubDate>Thu, 09 Nov 2017 09:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/411843#M100683</guid>
      <dc:creator>JT99</dc:creator>
      <dc:date>2017-11-09T09:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Turning one row into multiple rows based on length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/411850#M100687</link>
      <description>&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data have;
  id=1; number="65747 736356 837364 837336"; output;
  id=2; number="556773 6738373 8373839 677838"; output;
run;

data want (drop=i number);
  set have;
  number=compress(number);
  length want $4.;
  do i=1 to lengthn(number);
    want=cats(want,char(number,i));
    if mod(i,4)=0 then do;
      output;
      want="";
    end;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 10:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/411850#M100687</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-09T10:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Turning one row into multiple rows based on length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/411852#M100688</link>
      <description>&lt;P&gt;something like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Name$1-3 number$5-50;
datalines;
id1 65747 736356 837364 837336
id2 556773 6738373 8373839 677838
;

data want(keep=name num);
	set have;
	comp_number=compress(number);
	nchar=length(comp_number);
	do i=1 to nchar by 4;
		num=substr(comp_number, i, 4);
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 10:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/411852#M100688</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-11-09T10:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Turning one row into multiple rows based on length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/412190#M100809</link>
      <description>Thank you both for the help!&lt;BR /&gt;Is there a way to not delete spaces?&lt;BR /&gt;There is a space between the numbers and I want the space to be retained.</description>
      <pubDate>Fri, 10 Nov 2017 01:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/412190#M100809</guid>
      <dc:creator>JT99</dc:creator>
      <dc:date>2017-11-10T01:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Turning one row into multiple rows based on length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/412251#M100825</link>
      <description>&lt;P&gt;This is different to what you asked for in the first post.&amp;nbsp; Also, you should really show this as wanted output, i.e. what spaces are to be used.&amp;nbsp; As such you maybe able to modify &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;'s code slightly to:&lt;/P&gt;
&lt;PRE&gt;data have;&lt;BR /&gt; id=1; number="65747 736356 837364 837336"; output;&lt;BR /&gt; id=2; number="556773 6738373 8373839 677838"; output;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want (drop=i number);&lt;BR /&gt; set have;&lt;BR /&gt; length want $4.;&lt;BR /&gt; do i=1 to length(number) by 4;&lt;BR /&gt;   want=substr(number,i,4);&lt;BR /&gt;   output;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 09:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/412251#M100825</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-10T09:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Turning one row into multiple rows based on length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/412266#M100826</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/61512"&gt;@JT99&lt;/a&gt;, there doesn't seem to bee spaces in the desired output data you post? Always a good idea to be clear about what your desired data looks like.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 10:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Turning-one-row-into-multiple-rows-based-on-length/m-p/412266#M100826</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-11-10T10:17:46Z</dc:date>
    </item>
  </channel>
</rss>

