<?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: Duplicate rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-rows/m-p/321416#M70969</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

array no{*} AM1 AM2 AM3;
array no_new{*} AM1_ AM2_ AM3_;

do i=1 to dim(no);
 if no{i} ne 0 then 
	do;
	  do j=1 to dim(no);
	  	if j=i then no_new{j}=no{i};
		else  no_new{j}=0;
	  end;
      output;
	end;
end;

drop AM1-Am3 i j;

rename 
am1_=am1
am2_=am2
am3_=am3;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 28 Dec 2016 12:00:27 GMT</pubDate>
    <dc:creator>Loko</dc:creator>
    <dc:date>2016-12-28T12:00:27Z</dc:date>
    <item>
      <title>Duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-rows/m-p/321415#M70968</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new here, and very newbie on SAS, so forgive me by advance for the easy question I will ask.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with several rows and several data such as&lt;/P&gt;&lt;P&gt;- a text named "TE1"&lt;/P&gt;&lt;P&gt;- three amounts named "AM1", "AM2", "AM3"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each row, there is at least one of the three amounts not null, but for some rows two of them can be not null of even all three of them can be not null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is to create a new table with a program duplicating every row where at least two of the three amounts are not null, in order to have only one amount not null&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Exemple of table&lt;/P&gt;&lt;P&gt;TE1 AM1 AM2 AM3&lt;/P&gt;&lt;P&gt;AZZ 12 0 1&lt;/P&gt;&lt;P&gt;ABB 15 0 0&lt;/P&gt;&lt;P&gt;AFD 12 8 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to have in my new table&lt;/P&gt;&lt;P&gt;TE1 AM1 AM2 AM3&lt;/P&gt;&lt;P&gt;AZZ 12 0 0&lt;/P&gt;&lt;P&gt;AZZ 0 0 1&lt;/P&gt;&lt;P&gt;ABB 15 0 0&lt;/P&gt;&lt;P&gt;AFD 12 0 0&lt;/P&gt;&lt;P&gt;AFD 0 8 0&lt;/P&gt;&lt;P&gt;AFD 0 0 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tell me if it is not enough clear.&lt;/P&gt;&lt;P&gt;I have truly no ideas of how to do it. Can you help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 11:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Duplicate-rows/m-p/321415#M70968</guid>
      <dc:creator>Planck</dc:creator>
      <dc:date>2016-12-28T11:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-rows/m-p/321416#M70969</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

array no{*} AM1 AM2 AM3;
array no_new{*} AM1_ AM2_ AM3_;

do i=1 to dim(no);
 if no{i} ne 0 then 
	do;
	  do j=1 to dim(no);
	  	if j=i then no_new{j}=no{i};
		else  no_new{j}=0;
	  end;
      output;
	end;
end;

drop AM1-Am3 i j;

rename 
am1_=am1
am2_=am2
am3_=am3;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Dec 2016 12:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Duplicate-rows/m-p/321416#M70969</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-12-28T12:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Duplicate-rows/m-p/321419#M70970</link>
      <description>&lt;P&gt;Exactly what I needeed!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for the fast answer, and the efficiancy!&lt;/P&gt;&lt;P&gt;Happy new year 2017!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 12:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Duplicate-rows/m-p/321419#M70970</guid>
      <dc:creator>Planck</dc:creator>
      <dc:date>2016-12-28T12:18:08Z</dc:date>
    </item>
  </channel>
</rss>

