<?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 Adding Row by Group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-Row-by-Group/m-p/255700#M48886</link>
    <description>&lt;P&gt;I'm looking to take the first row of each group in a table and create an additional row that has the value from the first column (prod) in the second column (comp). Basically, this is an unbundling of a product, where a product ID has components attached to it, but the actual product ID itself should also be considered part of the bundle (one of the components) when joining to other tables.&lt;/P&gt;&lt;P&gt;Have:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Prod&lt;/TD&gt;&lt;TD&gt;Comp&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Prod&lt;/TD&gt;&lt;TD&gt;Comp&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Wed, 09 Mar 2016 23:13:55 GMT</pubDate>
    <dc:creator>Luke1234</dc:creator>
    <dc:date>2016-03-09T23:13:55Z</dc:date>
    <item>
      <title>Adding Row by Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Row-by-Group/m-p/255700#M48886</link>
      <description>&lt;P&gt;I'm looking to take the first row of each group in a table and create an additional row that has the value from the first column (prod) in the second column (comp). Basically, this is an unbundling of a product, where a product ID has components attached to it, but the actual product ID itself should also be considered part of the bundle (one of the components) when joining to other tables.&lt;/P&gt;&lt;P&gt;Have:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Prod&lt;/TD&gt;&lt;TD&gt;Comp&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Prod&lt;/TD&gt;&lt;TD&gt;Comp&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;x&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;y&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 09 Mar 2016 23:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Row-by-Group/m-p/255700#M48886</guid>
      <dc:creator>Luke1234</dc:creator>
      <dc:date>2016-03-09T23:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Row by Group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-Row-by-Group/m-p/255703#M48887</link>
      <description>&lt;P&gt;Use BY processing combined with an explicit output statement. You may have to tweak this if you want to maintain the order, and if you want to include character and numeric values in a single column - it will have to be a character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by prod;

if first.prod then do;
output;
comp=prod;
output;
end;
else output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Mar 2016 23:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-Row-by-Group/m-p/255703#M48887</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-09T23:25:20Z</dc:date>
    </item>
  </channel>
</rss>

