<?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 How to merge rows under the same ID with additional conditions? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913233#M83275</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-01-28 054817.png" style="width: 760px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93007i6FF3F7CBA8CF0123/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-01-28 054817.png" alt="Screenshot 2024-01-28 054817.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'd like to know, is there a way to merge data like what is shown in the figure? I have several observations under the same ID. I want to merge data based on both ID and Type. For the new data highlighted in the expected table, 13 is from the length 10+3, and 54 is from the weighted average of the two observations of Type 1 under ID 1 [(10x3+67x10)/(10+3)]. I also have other data in the database that need to be cleaned like this, so I would like to know if there are codes that I can apply to bulk change the structure of the dataset to the expected one.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Sun, 28 Jan 2024 11:14:38 GMT</pubDate>
    <dc:creator>LarissaW</dc:creator>
    <dc:date>2024-01-28T11:14:38Z</dc:date>
    <item>
      <title>How to merge rows under the same ID with additional conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913233#M83275</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-01-28 054817.png" style="width: 760px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93007i6FF3F7CBA8CF0123/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-01-28 054817.png" alt="Screenshot 2024-01-28 054817.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'd like to know, is there a way to merge data like what is shown in the figure? I have several observations under the same ID. I want to merge data based on both ID and Type. For the new data highlighted in the expected table, 13 is from the length 10+3, and 54 is from the weighted average of the two observations of Type 1 under ID 1 [(10x3+67x10)/(10+3)]. I also have other data in the database that need to be cleaned like this, so I would like to know if there are codes that I can apply to bulk change the structure of the dataset to the expected one.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2024 11:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913233#M83275</guid>
      <dc:creator>LarissaW</dc:creator>
      <dc:date>2024-01-28T11:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge rows under the same ID with additional conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913234#M83276</link>
      <description>&lt;P&gt;Why would you want to re-arrange this data at all? What can you do with the wide data set that you cannot do with the long data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sums, averages and weighted averages can all be computed from the original data without any re-arranging of the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
    class id type;
    var year;
    var dose/weight=year;
    output out=sum_dose sum(year)=year mean(dose)=dose;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Jan 2024 11:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913234#M83276</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-28T11:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge rows under the same ID with additional conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913235#M83277</link>
      <description>&lt;P&gt;Hi, thank you for your reply. I have to merge it to a single ID because I will merge this data with another database and use the merged dataset to do a Cox proportional analysis. I thought that the Cox model doesn't allow multiple observations with the same ID.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2024 11:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913235#M83277</guid>
      <dc:creator>LarissaW</dc:creator>
      <dc:date>2024-01-28T11:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge rows under the same ID with additional conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913236#M83278</link>
      <description>&lt;P&gt;As stated above, you can still do the calculations without re-arranging.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2024 12:02:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913236#M83278</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-28T12:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge rows under the same ID with additional conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913238#M83279</link>
      <description>&lt;P&gt;I'm still confused. If I want to merge two datasets, I think I should sort the data by ID first. The long data multiple observations with the same ID, then how is it possible to be merged with another dataset? Also, I think each row will be calculated as a sample, so if I have multiple rows with the same ID, the Cox proportional model will miscalculate the wrong categories.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2024 12:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913238#M83279</guid>
      <dc:creator>LarissaW</dc:creator>
      <dc:date>2024-01-28T12:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge rows under the same ID with additional conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913282#M83280</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/427928"&gt;@LarissaW&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm still confused. If I want to merge two datasets, I think I should sort the data by ID first. The long data multiple observations with the same ID, then how is it possible to be merged with another dataset? Also, I think each row will be calculated as a sample, so if I have multiple rows with the same ID, the Cox proportional model will miscalculate the wrong categories.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You haven't shown a second data set to involve any "merge". So you need to show that data set as well before any "merge" is discussed. And then what the appearance of that resulting merged data would look like.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2024 19:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-merge-rows-under-the-same-ID-with-additional-conditions/m-p/913282#M83280</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-28T19:01:33Z</dc:date>
    </item>
  </channel>
</rss>

