<?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: Combine rows in my dataset that are duplicates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914753#M360472</link>
    <description>Please show what you would expect as output.</description>
    <pubDate>Tue, 06 Feb 2024 20:13:30 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2024-02-06T20:13:30Z</dc:date>
    <item>
      <title>Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914750#M360470</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;I have a dataset that it something like this (can't post the original one because of confidential) but I'll do my best to explain it.&amp;nbsp; The dataset is not grouped och order by nothing, I just have ordered it here because it would be easier for you to read)&lt;BR /&gt;&lt;BR /&gt;The problem is that I have a dataset who looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;BOOKING(char)           AMOUNT(num)     DAYS(num)
1.2.3     Andersen      10              30 
1.2.4     Andersen      12              28 
1.2.4      Baker        whatever        whatever
1.2.5      Brown        whatever        whatever      
2.1.1      Clark         8               20
2.1.2      Clark          6               18


&lt;/PRE&gt;&lt;P&gt;You see that we have duplicates of &lt;STRONG&gt;Andersen&lt;/STRONG&gt; and &lt;STRONG&gt;Clark&lt;/STRONG&gt;. Because we have four &lt;EM&gt;different&lt;/EM&gt; families. How do I combine them? (recall that they're CHAR).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have tried:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;1. select &lt;STRONG&gt;distinct&amp;nbsp;&lt;/STRONG&gt; * from dataset GROUP BY 1 .&amp;nbsp;&lt;BR /&gt;- then I get duplicates ....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;&lt;SPAN&gt;&lt;SPAN class=""&gt;sum(&lt;STRONG&gt;BOOKING&lt;/STRONG&gt;)&lt;BR /&gt;- not working beacuse it is a char&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;BR /&gt;3.&amp;nbsp;proc sort data=dataset out=dataset2 nodupkey; by &lt;STRONG&gt;BOOKING&lt;/STRONG&gt;; run;&lt;BR /&gt;- still sees the duplicates and I guess it is because&amp;nbsp;is is different because&amp;nbsp;of the (1.2.3) and (1.2.4) thing that comes before the last name&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. sum(input(&lt;STRONG&gt;BOOKING&lt;/STRONG&gt;, best12.))as &lt;STRONG&gt;booking&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;- I get :&amp;nbsp;&lt;BR /&gt;NOTE: The query requires remerging summary statistics back with the original data.&lt;BR /&gt;NOTE: Invalid string.&lt;BR /&gt;NOTE: Invalid argument to function INPUT. Missing values may be generated.&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, 06 Feb 2024 19:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914750#M360470</guid>
      <dc:creator>melhaf</dc:creator>
      <dc:date>2024-02-06T19:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914751#M360471</link>
      <description>&lt;P&gt;I don't know how to edit my topic. But I want to summerize Andersen and Clark into one&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 19:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914751#M360471</guid>
      <dc:creator>melhaf</dc:creator>
      <dc:date>2024-02-06T19:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914753#M360472</link>
      <description>Please show what you would expect as output.</description>
      <pubDate>Tue, 06 Feb 2024 20:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914753#M360472</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-02-06T20:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914754#M360473</link>
      <description>&lt;P&gt;What do you want the single rows for&amp;nbsp;Andersen and Clark to contain? Is there a rule to decide which of the two rows in these examples is chosen?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 20:14:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914754#M360473</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-02-06T20:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914755#M360474</link>
      <description>Hi, I want to summarize them, so Andersen have together 10+12 AMOUNT,&lt;BR /&gt;30+28 DAYS and the same for Clark</description>
      <pubDate>Tue, 06 Feb 2024 20:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914755#M360474</guid>
      <dc:creator>melhaf</dc:creator>
      <dc:date>2024-02-06T20:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914757#M360475</link>
      <description>What happens with booking though? Since you seem to be trying to sum them. Showing the example output would be helpful.</description>
      <pubDate>Tue, 06 Feb 2024 20:33:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914757#M360475</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-02-06T20:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914758#M360476</link>
      <description>And is there two different variables, the booking and the name or are they one variable? If so, you very much want to separate those first.</description>
      <pubDate>Tue, 06 Feb 2024 20:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914758#M360476</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-02-06T20:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914760#M360477</link>
      <description>It dosen't happends anything with the code I posted. Or, I posted what the log said.</description>
      <pubDate>Tue, 06 Feb 2024 20:42:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914760#M360477</guid>
      <dc:creator>melhaf</dc:creator>
      <dc:date>2024-02-06T20:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914763#M360479</link>
      <description>&lt;P&gt;They are all the same the column is "1.2.3 Andersen" and then the other family is "1.2.4 Andersen" and I want to summerize families that have the name Andersen (and Clark in this example as well)&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 20:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914763#M360479</guid>
      <dc:creator>melhaf</dc:creator>
      <dc:date>2024-02-06T20:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914775#M360480</link>
      <description>&lt;P&gt;Not sure that I fully understood what you're asking for. Is below returning what you want?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input BOOKING $14. @15 AMOUNT DAYS;
 datalines;
1.2.3 Andersen 10 30 
1.2.4 Andersen 12 28 
1.2.4 Baker    1 1
1.2.5 Brown    1 1 
2.1.1 Clark    8 20
2.1.2 Clark    6 18
;

proc sql;
  select 
     substr(booking,find(booking,' ')) as booking_name
    ,sum(amount) as sum_amount
    ,sum(days) as sum_days
  from have
  group by booking_name
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1707256491751.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93318i051A77F1509AF197/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1707256491751.png" alt="Patrick_0-1707256491751.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 21:54:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/914775#M360480</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-06T21:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Combine rows in my dataset that are duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/915011#M360577</link>
      <description>&lt;P&gt;Thank you so much !&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 07:13:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-rows-in-my-dataset-that-are-duplicates/m-p/915011#M360577</guid>
      <dc:creator>melhaf</dc:creator>
      <dc:date>2024-02-08T07:13:10Z</dc:date>
    </item>
  </channel>
</rss>

