<?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: keeping tied values in a by group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896622#M354298</link>
    <description>&lt;P&gt;A simple typo &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Oct 2023 09:26:25 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2023-10-02T09:26:25Z</dc:date>
    <item>
      <title>keeping tied values in a by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896609#M354290</link>
      <description>&lt;P&gt;Hi everyone, I need help with this data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data m_data;&lt;BR /&gt;input group name $ val;&lt;BR /&gt;datalines;&lt;BR /&gt;1 pet 10&lt;BR /&gt;1 pet 15&lt;BR /&gt;2 jane 20&lt;BR /&gt;2 john 21&lt;BR /&gt;3 james 30&lt;BR /&gt;3 james 30&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sort data=m_data;&lt;BR /&gt;by group name descending val;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data tied_values;&lt;BR /&gt;set m_data;&lt;BR /&gt;by group name descending val;&lt;/P&gt;&lt;P&gt;if first.name;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=tied_values;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm trying to keep the first.name, in addition I want to keep values that are tied in the by group s&lt;/SPAN&gt;uch that my final dataset will give this;&lt;/P&gt;&lt;P&gt;1 pet 15&lt;BR /&gt;2 jane 20&lt;BR /&gt;2 john 21&lt;BR /&gt;3 james 30&lt;BR /&gt;3 james 30&lt;/P&gt;&lt;P&gt;Using the first.name alone will produce this;&lt;/P&gt;&lt;P&gt;1 pet 15&lt;BR /&gt;2 jane 20&lt;BR /&gt;2 john 21&lt;BR /&gt;3 james 30&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please what concept can I use to get this done.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 08:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896609#M354290</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-10-02T08:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: keeping tied values in a by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896612#M354291</link>
      <description>&lt;P&gt;I think this is what you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data m_data;
input group name $ val;
datalines;
1 pet 10
1 pet 15
2 jane 20
2 john 21
3 james 30
3 james 30
;

proc sql;
   create table want as
   select *
   from m_data
   group by group, name
   having max(val) = val
   order by group
   ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Oct 2023 09:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896612#M354291</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-10-02T09:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: keeping tied values in a by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896613#M354292</link>
      <description>The row/observation "3 james 30" is present twice in the input/source dataset so sort with first logic will not allow a result as you wish.&lt;BR /&gt;What is the logic behind keeping these 2 exactly the same observations/rows?</description>
      <pubDate>Mon, 02 Oct 2023 08:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896613#M354292</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2023-10-02T08:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: keeping tied values in a by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896620#M354296</link>
      <description>&lt;P&gt;I'm trying to select max value(val) per group per name with the condition to keep tie values(val)&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 09:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896620#M354296</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-10-02T09:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: keeping tied values in a by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896621#M354297</link>
      <description>&lt;P&gt;This works. If I may ask, what's the logic behind listing the group variable twice in the order by statement?&lt;/P&gt;&lt;P&gt;Can this same code/logic be implemented in a data step as well?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3492"&gt;@JosvanderVelden&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 09:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896621#M354297</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-10-02T09:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: keeping tied values in a by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896622#M354298</link>
      <description>&lt;P&gt;A simple typo &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 09:26:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896622#M354298</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-10-02T09:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: keeping tied values in a by group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896623#M354299</link>
      <description>&lt;P&gt;Okay thank you very much.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 09:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-tied-values-in-a-by-group/m-p/896623#M354299</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-10-02T09:29:34Z</dc:date>
    </item>
  </channel>
</rss>

