<?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: How to combine rows into one in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331497#M74504</link>
    <description>&lt;P&gt;(simplistic &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ) solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data A;
  Format Name $8. Value 8. BodyPart $8. UnknownVar $12. Value2 8.;
  Input Name $ Value BodyPart $ UnknownVar $ Value2; 
  Datalines;
Jack 500 head . 23
Jack . head patil 23
Tim 100 shoulder . 24
Tim 100 . Dufwenberg .
;
* ^^^ check if this is similar to your data here ..;

Data B (Keep=Dummy:
		Rename=(DummyName=Name 
				DummyValue=Value
				DummyBodyPart=BodyPart
				DummyUnknownVar=UnknownVar
				DummyValue2=Value2)); 
  Set A;
  Format DummyName $8. DummyValue 8. DummyBodyPart $8. DummyUnknownVar $12. DummyValue2 8.;
  Retain DummyName DummyValue DummyBodyPart DummyUnknownVar DummyValue2;
  By /*Notsorted*/ Name;
  If not Missing (Name) Then DummyName=Name; * hm, different var types are a bit awkward ..;
  If not Missing (Value) Then DummyValue=Value; * .. could try array otherwise ..;
  If not Missing (BodyPart) Then DummyBodyPart=BodyPart; * .. or maybe call execute;
  If not Missing (UnknownVar) Then DummyUnknownVar=UnknownVar;
  If not Missing (Value2) Then DummyValue2=Value2;
  If Last.Name Then Output;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 10 Feb 2017 13:32:40 GMT</pubDate>
    <dc:creator>user24feb</dc:creator>
    <dc:date>2017-02-10T13:32:40Z</dc:date>
    <item>
      <title>How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331471#M74496</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to combine two rows of data with&amp;nbsp;missing information in different rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jack / 500 / head / &amp;nbsp; &amp;nbsp; / 23&lt;/P&gt;&lt;P&gt;Jack / &amp;nbsp; &amp;nbsp; &amp;nbsp; / head / patil / 23&lt;/P&gt;&lt;P&gt;Tim / 100 / shoulder/ &amp;nbsp; &amp;nbsp; / 24&lt;/P&gt;&lt;P&gt;Tim / 100 / &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/ Dufwenberg / &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The end result would be:&lt;/P&gt;&lt;P&gt;Jack / 500 / head / patil / 23&lt;/P&gt;&lt;P&gt;Tim / 100 / shoulder/ &lt;SPAN&gt;Dufwenberg&lt;/SPAN&gt;&amp;nbsp;/ 24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions of how to perform this in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Jack&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 12:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331471#M74496</guid>
      <dc:creator>jackmelbourne</dc:creator>
      <dc:date>2017-02-10T12:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331479#M74499</link>
      <description>&lt;P&gt;Is this the only case you have, duplicates on two rows, and all non missing values are the same?&lt;/P&gt;
&lt;P&gt;I would try to use SQL with max() for this specific scenario.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 12:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331479#M74499</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-02-10T12:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331483#M74500</link>
      <description>&lt;P&gt;Well, not typing that in, so this is just examples (note: post test data in the form of a datastep for better answers):&lt;/P&gt;
&lt;P&gt;Sort and merge each variable with column1&lt;/P&gt;
&lt;P&gt;Use retain statements in one datatep and only output at last.column1&lt;/P&gt;
&lt;P&gt;Transpose the data and sort nodupkey.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 13:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331483#M74500</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-10T13:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331495#M74503</link>
      <description>&lt;P&gt;Sorry, maybe I could make my question a bit clearer with this dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset: housing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Name &amp;nbsp; &amp;nbsp; &amp;nbsp; Age &amp;nbsp; &amp;nbsp; &amp;nbsp;Net&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Reg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loss&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;home&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;300&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;home &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 80 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;P&gt;TDR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 80&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 75 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;TDR &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;70 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to transform the housing data set to look like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Name &amp;nbsp; &amp;nbsp; &amp;nbsp; Age &amp;nbsp; &amp;nbsp; &amp;nbsp;Net&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Reg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loss&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;home &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 80 &amp;nbsp; &amp;nbsp; &amp;nbsp;50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;TDR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 80&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 75&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What code would you recommend?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 13:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331495#M74503</guid>
      <dc:creator>jackmelbourne</dc:creator>
      <dc:date>2017-02-10T13:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331497#M74504</link>
      <description>&lt;P&gt;(simplistic &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ) solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data A;
  Format Name $8. Value 8. BodyPart $8. UnknownVar $12. Value2 8.;
  Input Name $ Value BodyPart $ UnknownVar $ Value2; 
  Datalines;
Jack 500 head . 23
Jack . head patil 23
Tim 100 shoulder . 24
Tim 100 . Dufwenberg .
;
* ^^^ check if this is similar to your data here ..;

Data B (Keep=Dummy:
		Rename=(DummyName=Name 
				DummyValue=Value
				DummyBodyPart=BodyPart
				DummyUnknownVar=UnknownVar
				DummyValue2=Value2)); 
  Set A;
  Format DummyName $8. DummyValue 8. DummyBodyPart $8. DummyUnknownVar $12. DummyValue2 8.;
  Retain DummyName DummyValue DummyBodyPart DummyUnknownVar DummyValue2;
  By /*Notsorted*/ Name;
  If not Missing (Name) Then DummyName=Name; * hm, different var types are a bit awkward ..;
  If not Missing (Value) Then DummyValue=Value; * .. could try array otherwise ..;
  If not Missing (BodyPart) Then DummyBodyPart=BodyPart; * .. or maybe call execute;
  If not Missing (UnknownVar) Then DummyUnknownVar=UnknownVar;
  If not Missing (Value2) Then DummyValue2=Value2;
  If Last.Name Then Output;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Feb 2017 13:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331497#M74504</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2017-02-10T13:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331502#M74507</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/128407"&gt;@jackmelbourne&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Sorry, maybe I could make my question a bit clearer with this dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dataset: housing&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Name &amp;nbsp; &amp;nbsp; &amp;nbsp; Age &amp;nbsp; &amp;nbsp; &amp;nbsp;Net&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Reg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loss&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;home&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;300&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 200&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;home &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#ff0000"&gt;&amp;nbsp;100&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt; 80 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;
&lt;P&gt;TDR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color="#0000ff"&gt;80&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 75 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;TDR &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#ff0000"&gt;&amp;nbsp;70 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/FONT&gt; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to transform the housing data set to look like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Name &amp;nbsp; &amp;nbsp; &amp;nbsp; Age &amp;nbsp; &amp;nbsp; &amp;nbsp;Net&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Reg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loss&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;home &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;FONT color="#ff0000"&gt;100&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 80 &amp;nbsp; &amp;nbsp; &amp;nbsp;50 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;
&lt;P&gt;TDR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color="#ff0000"&gt;80&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 75&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What code would you recommend?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why does age 100 update 300 for NAME=HOME while age 70 does not update 80 for NAME=TDR?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 13:47:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331502#M74507</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-02-10T13:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331506#M74508</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, should have made that clearer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the lower value for home and the higher value for TDR when there are values for both observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jack&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 13:57:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331506#M74508</guid>
      <dc:creator>jackmelbourne</dc:creator>
      <dc:date>2017-02-10T13:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331507#M74509</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/128407"&gt;@jackmelbourne&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry, should have made that clearer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need the lower value for home and the higher value for TDR when there are values for both observations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Jack&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And the other variables update to last non-missing?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 13:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331507#M74509</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-02-10T13:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331509#M74511</link>
      <description>&lt;P&gt;Yes, exactly.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 14:02:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331509#M74511</guid>
      <dc:creator>jackmelbourne</dc:creator>
      <dc:date>2017-02-10T14:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331513#M74512</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/128407"&gt;@jackmelbourne&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Yes, exactly.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Updating to last non-missing is standard UPDATE statement.&amp;nbsp; The conditional min/max makes for a bit of extra code for AGE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input Name :$upcase4. Age Net Reg Loss;
   cards;
home 300 200 50     .
home 100 80   .     5
TDR  80  75   .     3
TDR  70   .   5     .
;;;;
   run;
proc print;
   run;
data want;
   if 0 then set have;
   update have(keep=name obs=0) have(drop=age);
   by name;
   if first.name then age=.;
   set have(keep=age rename=(age=_age));
   select(name);
      when('HOME') age = min(age,_age);
      when('TDR')  age = max(age,_age);
      end;
   drop _age;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG title="Capture.PNG" alt="Capture.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/7155iE87E65751BF8457D/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 14:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331513#M74512</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-02-10T14:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331545#M74527</link>
      <description>&lt;P&gt;Perfect, thank you so much! Seems to work &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 15:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331545#M74527</guid>
      <dc:creator>jackmelbourne</dc:creator>
      <dc:date>2017-02-10T15:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine rows into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331601#M74550</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Keep the last non-missing value for each variable

I think there is an error in you 'want' table
TDR(AGE)=70 not 80


HAVE
====

Up to 40 obs WORK.HAVE total obs=4

Obs    NAME   AGE  NET  REG  LOSS

 1     home   300  200   50     .
 2     home   100   80    .     5
 3     TDR     80   75    .     3
 4     TDR     70    .    5     .

WANT
====

Obs    NAME   AGE  NET  REG  LOSS

 1     home   100   80   50     5
 2     TDR     70   75    5     3

SOLUTION

* I set this up to work with an arbitrary number of numeric columns;
* Do not need disubl if you hardcode variable names;
* I wish SAS would make the number of coluns available at compilation time;
data have;
input Name $ Age Net Reg Loss;
cards4;
home 300 200 50 .
home 100 80 . 5
TDR 80 75 . 3
TDR 70 . 5 .
;;;;
run;quit;

data _null_;
    set have(obs=1);
    array nums _numeric_;
    call symputx('nums',put(dim(nums),5.));
    rc=dosubl('
      data want;
        set have;
        by name notsorted;
        array nums _numeric_;
        array savs[&amp;amp;nums.] _temporary_;
        do i=1 to dim(nums);
          if nums[i] ne . then savs[i]=nums[i];
        end;
        do i=1 to dim(nums);
          nums[i]=savs[i];
        end;
        if last.name then output;
      run;quit;
    ');
run;quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Feb 2017 17:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-rows-into-one/m-p/331601#M74550</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-02-10T17:25:05Z</dc:date>
    </item>
  </channel>
</rss>

