<?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 by ID to a single row, without data disappearing? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804566#M33423</link>
    <description>Here is an example of what I mean&lt;BR /&gt;&lt;BR /&gt;What I have:&lt;BR /&gt;ColA Col1 Col2 Col3 Col4 Col4 Col5 Col6 ... Col11 ID&lt;BR /&gt;Z123 1&lt;BR /&gt;H456 E125 T158 1&lt;BR /&gt;Z123 T158 E125 1&lt;BR /&gt;&lt;BR /&gt;What I want&lt;BR /&gt;ColA Col1 Col2 Col3 Col4 Col4 Col5 Col6 ... Col11 ID&lt;BR /&gt;Z123 H456 E125 T158 1</description>
    <pubDate>Mon, 28 Mar 2022 16:43:14 GMT</pubDate>
    <dc:creator>steiner28</dc:creator>
    <dc:date>2022-03-28T16:43:14Z</dc:date>
    <item>
      <title>How to Combine Rows by ID to a single row, without data disappearing?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804556#M33421</link>
      <description>&lt;P&gt;I am trying to combine observations by ID, using 12 different variables. I am checking for duplicate ID's and trying to combine them into one observation. Below is the code I am currently using, but every time I go to the dataset, one of the observations takes over, and the others seem to disappear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data = test;&lt;BR /&gt;by ID;&lt;BR /&gt;run;&lt;BR /&gt;data have;&lt;BR /&gt;update dup (obs=0) dup;&lt;BR /&gt;by ID;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select PDIAG10, SDIAG10_1, SDIAG10_2,SDIAG10_3,SDIAG10_4,SDIAG10_5,SDIAG10_6,SDIAG10_7,SDIAG10_8,SDIAG10_9,SDIAG10_10, SDIAG10_11, VISIT_ID, AGE, DOS_MY, hTYPE, ER, gender, ID, RACE, Married&lt;BR /&gt;from have&lt;BR /&gt;group by ID;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="one.jpg" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69878iF7F6709C20A88C78/image-size/small?v=v2&amp;amp;px=200" role="button" title="one.jpg" alt="one.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="two.jpg" style="width: 189px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69881i4719894AC6CD67BF/image-size/small?v=v2&amp;amp;px=200" role="button" title="two.jpg" alt="two.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804556#M33421</guid>
      <dc:creator>steiner28</dc:creator>
      <dc:date>2022-03-28T16:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Rows by ID to a single row, without data disappearing?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804557#M33422</link>
      <description>&lt;P&gt;Please show an example of what you are talking about.&lt;/P&gt;
&lt;P&gt;Post (as TEXT not PHOTOGRAPHS) a few observations for the same ID with two or three other variables.&lt;/P&gt;
&lt;P&gt;Show what you want as the output once the observations (which I assume is what you meant by rows) are "combined".&amp;nbsp; Again show the result as TEXT.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804557#M33422</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-28T16:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Rows by ID to a single row, without data disappearing?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804566#M33423</link>
      <description>Here is an example of what I mean&lt;BR /&gt;&lt;BR /&gt;What I have:&lt;BR /&gt;ColA Col1 Col2 Col3 Col4 Col4 Col5 Col6 ... Col11 ID&lt;BR /&gt;Z123 1&lt;BR /&gt;H456 E125 T158 1&lt;BR /&gt;Z123 T158 E125 1&lt;BR /&gt;&lt;BR /&gt;What I want&lt;BR /&gt;ColA Col1 Col2 Col3 Col4 Col4 Col5 Col6 ... Col11 ID&lt;BR /&gt;Z123 H456 E125 T158 1</description>
      <pubDate>Mon, 28 Mar 2022 16:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804566#M33423</guid>
      <dc:creator>steiner28</dc:creator>
      <dc:date>2022-03-28T16:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Rows by ID to a single row, without data disappearing?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804567#M33424</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;What I have:&lt;BR /&gt;ColA Col1 Col2 Col3 Col4 Col4 Col5 Col6 ... Col11 ID
Z123                                              1
H456 E125 T158                                    1
Z123 T158 E125                                    1

What I want:
ColA      Col1   Col2 Col3 Col4 Col4 Col5 Col6 ... Col11 ID
Z123 H456 E125   T158                                    1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sorry about the previous reply! I haven't used this before.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804567#M33424</guid>
      <dc:creator>steiner28</dc:creator>
      <dc:date>2022-03-28T16:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Rows by ID to a single row, without data disappearing?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804570#M33425</link>
      <description>&lt;P&gt;If kind of looks like that instead picking just one of the values of a variable, say COL1, you want to create a &lt;STRONG&gt;different type of variable&lt;/STRONG&gt; that can hold multiple values?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 17:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804570#M33425</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-28T17:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Rows by ID to a single row, without data disappearing?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804630#M33427</link>
      <description>&lt;P&gt;You have not stated your rules for constructing the new values of COLA, COL1, .....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;It appears you want to output 1 record per id, correct?&lt;/LI&gt;
&lt;LI&gt;The new COLA appears to be a space-separated list of the unique values that appear in the old COLA series, in the order that those unique values occur.&lt;/LI&gt;
&lt;LI&gt;The new COL1 and new COL2&amp;nbsp; (and COL3-COL11?) variables appear to have whatever was the first non-missing value for those variables in the old dataset.&amp;nbsp; Is that correct?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 21:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804630#M33427</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-03-28T21:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Rows by ID to a single row, without data disappearing?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804635#M33428</link>
      <description>&lt;P&gt;If the answers to my questions are all "yes", then this program would produce the results you describe:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=_:);
  length cola $34 ;
  retain cola;
  set have (keep=rename=(cola=_old_cola));
  by id;
  if findw(cola,trim(_old_cola),' ')=0 then cola=catx(' ',cola,_old_cola);

  array col     col1-col11;
  array _tmp $4 _tmp1-_tmp11;
  do over _tmp;  _tmp=coalescec(_tmp,col); end;

  if last.id;
  do over col;   col=_tmp;                 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Mar 2022 21:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804635#M33428</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-03-28T21:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Rows by ID to a single row, without data disappearing?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804636#M33429</link>
      <description>The answer to your first question is yes!&lt;BR /&gt;2. I need all of the columns, COLA-COL11 to be space separated that only store unique values.&lt;BR /&gt;3. For COLA-COL11, I just need no duplicates across the row.&lt;BR /&gt;&lt;BR /&gt;Long-term I am calculating the CCI for data, and I need each ID (i.e person) to only be counted once.</description>
      <pubDate>Mon, 28 Mar 2022 21:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804636#M33429</guid>
      <dc:creator>steiner28</dc:creator>
      <dc:date>2022-03-28T21:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to Combine Rows by ID to a single row, without data disappearing?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804668#M33433</link>
      <description>&lt;P&gt;Let's clarify a little more.&amp;nbsp; Your requirements are still not entirely clear to me.&amp;nbsp; I now think you want&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;List all unique values, from the old COLA, in the order encountered, in the new COLA.&lt;/LI&gt;
&lt;LI&gt;List all unique values, from the old COL1, and not found in the old COLA, in the new COL1.&lt;/LI&gt;
&lt;LI&gt;List all unique values, from the old COL2, and not found in the old COLA or old COL1, in the new COL2.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, each new COL will have unique values found in that COL, but not found in the COLs to its left.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the above correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 05:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Combine-Rows-by-ID-to-a-single-row-without-data/m-p/804668#M33433</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-03-29T05:23:42Z</dc:date>
    </item>
  </channel>
</rss>

