<?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: Split(insert) rows acording values in column in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72162#M20899</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since I have the ready-to-go sample set from &lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" href="https://communities.sas.com/people/polingjw" id="jive-41761232761922187979803"&gt;polingjw&lt;/A&gt; , only a minor change to his/her code will do.here is what I came up with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input no part $ qty;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 A100 2&lt;/P&gt;&lt;P&gt;5 B100 3&lt;/P&gt;&lt;P&gt;25 A100 1&lt;/P&gt;&lt;P&gt;35 B100 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(keep=no part qty);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have(rename=(qty=oldqty));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain qty 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do _n_=1 to oldqty;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part=ifc(_n_=1,part,'');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Mar 2012 20:31:50 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-03-20T20:31:50Z</dc:date>
    <item>
      <title>Split(insert) rows acording values in column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72157#M20894</link>
      <description>Hi All&lt;BR /&gt;
Can anybody help me.&lt;BR /&gt;
&lt;BR /&gt;
My data:&lt;BR /&gt;
no	part	qty&lt;BR /&gt;
1	A100	2&lt;BR /&gt;
5	B100	3&lt;BR /&gt;
25	A100	1&lt;BR /&gt;
35	B100	2&lt;BR /&gt;
&lt;BR /&gt;
This is what I want as result:&lt;BR /&gt;
no	part	qty&lt;BR /&gt;
1	A100	1&lt;BR /&gt;
1	A100	1&lt;BR /&gt;
5	B100	1&lt;BR /&gt;
5	B100	1&lt;BR /&gt;
5	B100	1&lt;BR /&gt;
25	C100	1&lt;BR /&gt;
35	B100	1&lt;BR /&gt;
35	B100	1&lt;BR /&gt;
&lt;BR /&gt;
In first row is “no” =1 ,” part” = A100 and “qty” =2. I want to split in to two (this number depends on number in “qty” column) rows and change “qty” to 1. Second row will be split in to 3 rows bwcause “qty” is 3. Third row don’t need any change because “qty” is 1 etc.&lt;BR /&gt;
Thank you in advance&lt;BR /&gt;
Bob</description>
      <pubDate>Thu, 02 Jun 2011 14:44:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72157#M20894</guid>
      <dc:creator>bob021</dc:creator>
      <dc:date>2011-06-02T14:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Split(insert) rows acording values in column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72158#M20895</link>
      <description>[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
input no part $ qty;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 A100 2&lt;BR /&gt;
5 B100 3&lt;BR /&gt;
25 A100 1&lt;BR /&gt;
35 B100 2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want(keep=no part qty);&lt;BR /&gt;
	set have(rename=(qty=oldqty));&lt;BR /&gt;
	retain qty 1;&lt;BR /&gt;
	do i=1 to oldqty;&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 02 Jun 2011 14:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72158#M20895</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2011-06-02T14:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: Split(insert) rows acording values in column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72159#M20896</link>
      <description>I'm not sure what analysis you may be doing but if it may be that you could leave the data as is and use the variable QTY as either a WEIGHT or FREQ variable.&lt;BR /&gt;
&lt;BR /&gt;
Proc freq;&lt;BR /&gt;
table no*part;&lt;BR /&gt;
weight qty;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Otherwise;&lt;BR /&gt;
&lt;BR /&gt;
in a data step &lt;BR /&gt;
&lt;BR /&gt;
Data newdata;&lt;BR /&gt;
set mydata;&lt;BR /&gt;
max=qty;&lt;BR /&gt;
Do i= 1 to MAX;&lt;BR /&gt;
   qty=1;&lt;BR /&gt;
   output;&lt;BR /&gt;
end;&lt;BR /&gt;
drop i max;&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 02 Jun 2011 18:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72159#M20896</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-06-02T18:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Split(insert) rows acording values in column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72160#M20897</link>
      <description>Hi Polingjw and Ballardw &lt;BR /&gt;
Thank you for your responses. Both solutions working like a charm.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again.&lt;BR /&gt;
Bob</description>
      <pubDate>Fri, 03 Jun 2011 09:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72160#M20897</guid>
      <dc:creator>bob021</dc:creator>
      <dc:date>2011-06-03T09:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Split(insert) rows acording values in column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72161#M20898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a similar problem, so I was happy to find this post!&amp;nbsp; However, mine is a little bit different since I want to extra rows to be blank except for the identifier column.&amp;nbsp; For example, starting with Table HAVE:&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 100%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Name&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Data Columns&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Feb&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Feb&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to get to Table WANT:&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 100%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Name&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Data Columns&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Feb&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Feb&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;The second row in Table WANT is the "inserted row" with missing values in the Data Columns.&amp;nbsp; Using your code and a column that indicates when and how many rows to insert, I can insert the wanted extra row but the value in Data Columns is X.&amp;nbsp; Now I want to set X to missing, but only for the added row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Help?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2012 19:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72161#M20898</guid>
      <dc:creator>TRCWard</dc:creator>
      <dc:date>2012-03-20T19:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Split(insert) rows acording values in column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72162#M20899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since I have the ready-to-go sample set from &lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" href="https://communities.sas.com/people/polingjw" id="jive-41761232761922187979803"&gt;polingjw&lt;/A&gt; , only a minor change to his/her code will do.here is what I came up with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input no part $ qty;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 A100 2&lt;/P&gt;&lt;P&gt;5 B100 3&lt;/P&gt;&lt;P&gt;25 A100 1&lt;/P&gt;&lt;P&gt;35 B100 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want(keep=no part qty);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have(rename=(qty=oldqty));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain qty 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do _n_=1 to oldqty;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part=ifc(_n_=1,part,'');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2012 20:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72162#M20899</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-20T20:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Split(insert) rows acording values in column</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72163#M20900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; On the code where you are adding the row follow with something like "VAR = .;" before the additional output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suspect you have a logical condition being and if you are useing an IF - THEN structure to create the additional row you may need to use a DO - END to get the assignment in right place. If you have a lot of variables an array could be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example of your almost working code would provide a better start point.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2012 20:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Split-insert-rows-acording-values-in-column/m-p/72163#M20900</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-03-20T20:37:36Z</dc:date>
    </item>
  </channel>
</rss>

