<?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 Is there any way to separate multiple records from one cell into one record per row? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311455#M67312</link>
    <description>&lt;P&gt;I have tens of thousands records shown in the below format. Example:&amp;nbsp;one aggregate amount ($3200) for multiple invoice numbers (32, 33, 34, 35). Here is how I created by using Proc SQL:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE TABLE INVENTORY AS&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;DATE,&lt;/P&gt;&lt;P&gt;AMOUNT,&lt;/P&gt;&lt;P&gt;INVOICE&lt;/P&gt;&lt;P&gt;FROM DATA.DATA;&lt;/P&gt;&lt;P&gt;WHERE DATE = '31OCT2016'D;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Invoice #&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/31/2016&lt;/TD&gt;&lt;TD&gt;3200&lt;/TD&gt;&lt;TD&gt;32, 33, 34, 35&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now the question is:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Is there any way that I could put the invoice # into different rows while keeping the aggregate amount of $3200 in the first row only? Like Below:&lt;/FONT&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Invoice #&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/31/2016&lt;/TD&gt;&lt;TD&gt;3200&lt;/TD&gt;&lt;TD&gt;32&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/31/2016&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/31/2016&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;34&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/31/2016&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Thanks &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Nov 2016 16:43:37 GMT</pubDate>
    <dc:creator>LL5</dc:creator>
    <dc:date>2016-11-14T16:43:37Z</dc:date>
    <item>
      <title>Is there any way to separate multiple records from one cell into one record per row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311455#M67312</link>
      <description>&lt;P&gt;I have tens of thousands records shown in the below format. Example:&amp;nbsp;one aggregate amount ($3200) for multiple invoice numbers (32, 33, 34, 35). Here is how I created by using Proc SQL:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE TABLE INVENTORY AS&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;DATE,&lt;/P&gt;&lt;P&gt;AMOUNT,&lt;/P&gt;&lt;P&gt;INVOICE&lt;/P&gt;&lt;P&gt;FROM DATA.DATA;&lt;/P&gt;&lt;P&gt;WHERE DATE = '31OCT2016'D;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Invoice #&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/31/2016&lt;/TD&gt;&lt;TD&gt;3200&lt;/TD&gt;&lt;TD&gt;32, 33, 34, 35&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now the question is:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Is there any way that I could put the invoice # into different rows while keeping the aggregate amount of $3200 in the first row only? Like Below:&lt;/FONT&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Invoice #&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/31/2016&lt;/TD&gt;&lt;TD&gt;3200&lt;/TD&gt;&lt;TD&gt;32&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/31/2016&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/31/2016&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;34&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/31/2016&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Thanks &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2016 16:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311455#M67312</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2016-11-14T16:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to separate multiple records from one cell into one record per row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311484#M67335</link>
      <description>&lt;P&gt;This is easy in a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want to put an output statement into a loop where invoice=32, then 33, then 34, then 35.&amp;nbsp; But after the first output, you want to set amount to a missing value.&amp;nbsp;&amp;nbsp; So the real issue is how to make&amp;nbsp;a loop over the character variable INVOICELIST (="32,33,34,35").&amp;nbsp; This program does that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Use the COUNTW function to find the number of "words" in invoicelist (where a word in this case is delimited by commas).&lt;/LI&gt;
&lt;LI&gt;Use the SCAN functino to retrieve those words in succession.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  attrib date format=mmddyys10.
         amount length=8
		 invoicelist length=$20;
  input date mmddyy10.  amount   invoicelist;
datalines;
10/31/2016 3200  32,33,34,35
run;

data want;
  set have;
  do I=1 to countw(invoicelist,',');
    invoice=input(scan(invoicelist,I,','),4.);
	output;
	amount=.;
  end;
  drop invoicelist;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2016 18:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311484#M67335</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-11-14T18:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to separate multiple records from one cell into one record per row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311568#M67378</link>
      <description>Thanks! I'm curious if I have huge amounts of data, do I have to put them all below the datalines statement?</description>
      <pubDate>Tue, 15 Nov 2016 00:41:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311568#M67378</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2016-11-15T00:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to separate multiple records from one cell into one record per row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311570#M67379</link>
      <description>&lt;P&gt;You don't use DATALINES for large amounts of data. You read directly from an external file instead. Check out the INFILE statement.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2016 00:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311570#M67379</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-11-15T00:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to separate multiple records from one cell into one record per row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311571#M67380</link>
      <description>I see. Got it. Thanks.</description>
      <pubDate>Tue, 15 Nov 2016 00:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-separate-multiple-records-from-one-cell-into/m-p/311571#M67380</guid>
      <dc:creator>LL5</dc:creator>
      <dc:date>2016-11-15T00:53:37Z</dc:date>
    </item>
  </channel>
</rss>

