<?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 Grouping Data in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516364#M3130</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 3 columns in my table - category, name and count&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is arranged&amp;nbsp;by Category and count(desc)&lt;/P&gt;&lt;P&gt;I want the data to be grouped based on the category and the top 2 counts AND the rest (for that category) grouped together as Othr with the total of the counts(for that category) ..&lt;/P&gt;&lt;P&gt;eg: Below is the data I have :&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input Cat $5. name $5. count ;&lt;BR /&gt;datalines;&lt;BR /&gt;Tech john 100&lt;BR /&gt;Tech Harr 90&lt;BR /&gt;Tech Rick 60&lt;BR /&gt;Tech Ronn 50&lt;BR /&gt;Food Gini 20&lt;BR /&gt;Food kell 15&lt;BR /&gt;Food Dina 10&lt;BR /&gt;Cars Rini 50&lt;BR /&gt;Cars Holl 40&lt;BR /&gt;Cars Radd 30&lt;BR /&gt;Cars lola 20&lt;BR /&gt;Cars Lili 50&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output I want is :&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tech john 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tech Harr 90&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tech Othr 110&amp;nbsp; &amp;nbsp; &amp;nbsp;/* which is 60+50 for the remaining Tech*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Food Gini 20&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Food kell 15&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Food Othr 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cars Rini 50&lt;BR /&gt;Cars Holl 40&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cars Othr 100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can this be done?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for the help in advance:)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Nov 2018 16:04:10 GMT</pubDate>
    <dc:creator>new_sas_user_4</dc:creator>
    <dc:date>2018-11-27T16:04:10Z</dc:date>
    <item>
      <title>Grouping Data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516364#M3130</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 3 columns in my table - category, name and count&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is arranged&amp;nbsp;by Category and count(desc)&lt;/P&gt;&lt;P&gt;I want the data to be grouped based on the category and the top 2 counts AND the rest (for that category) grouped together as Othr with the total of the counts(for that category) ..&lt;/P&gt;&lt;P&gt;eg: Below is the data I have :&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input Cat $5. name $5. count ;&lt;BR /&gt;datalines;&lt;BR /&gt;Tech john 100&lt;BR /&gt;Tech Harr 90&lt;BR /&gt;Tech Rick 60&lt;BR /&gt;Tech Ronn 50&lt;BR /&gt;Food Gini 20&lt;BR /&gt;Food kell 15&lt;BR /&gt;Food Dina 10&lt;BR /&gt;Cars Rini 50&lt;BR /&gt;Cars Holl 40&lt;BR /&gt;Cars Radd 30&lt;BR /&gt;Cars lola 20&lt;BR /&gt;Cars Lili 50&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output I want is :&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tech john 100&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tech Harr 90&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tech Othr 110&amp;nbsp; &amp;nbsp; &amp;nbsp;/* which is 60+50 for the remaining Tech*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Food Gini 20&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Food kell 15&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Food Othr 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cars Rini 50&lt;BR /&gt;Cars Holl 40&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cars Othr 100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can this be done?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for the help in advance:)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 16:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516364#M3130</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-11-27T16:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516370#M3133</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Cat $ name $ count ;
datalines;
Tech john 100
Tech Harr 90
Tech Rick 60
Tech Ronn 50
Food Gini 20
Food kell 15
Food Dina 10
Cars Rini 50
Cars Holl 40
Cars Radd 30
Cars lola 20
Cars Lili 50
;

data want;
do _n_=1 by 1 until(last.cat);
set have;
by cat notsorted;
if _n_&amp;gt;2 then temp=sum(count,temp);
if last.cat then do;
name='Other';
count=temp;
end;
if _n_&amp;lt;=2 or last.cat then output;
end;
drop temp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Nov 2018 16:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516370#M3133</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-27T16:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516388#M3140</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;thanks a lot!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please suggest a few topics that I should study or practice to be able to write such queries by myself?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 16:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516388#M3140</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-11-27T16:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516393#M3143</link>
      <description>&lt;P&gt;Basically, I rely on books by Author Ron Cody Learning SAS by example . Top notch book in my opinion especially the 2nd edition&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then SAS functions by the same author Ron cody&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For macros, I think author is Art carpenter&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But first try to get hold of the top one i.e&amp;nbsp;&lt;SPAN&gt;Author Ron Cody Learning SAS by example&amp;nbsp;. Read page by page, line by line by taking your time all that you need, Trust me, you will start helping others users with your super codes.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;PS&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I myself can't believe for real how amazing that book is, It's unreal and classic&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 16:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516393#M3143</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-27T16:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516401#M3147</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the book&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Author Ron Cody Learning SAS by example&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt; is good for a basic SAS user like me?(to start) &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 16:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516401#M3147</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-11-27T16:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516406#M3150</link>
      <description>&lt;P&gt;That book helped a spoiled only child IKEA fork lift driver, pubaholic who played nintendo, sega, play station, xbox to where I am today. That must mean something? lol&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 16:46:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516406#M3150</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-27T16:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516413#M3154</link>
      <description>&lt;P&gt;I look up to you for SAS!!&amp;nbsp;Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I am going to get that book!!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 16:52:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516413#M3154</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-11-27T16:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Data</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516414#M3155</link>
      <description>&lt;P&gt;Indeed &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; the way to go. I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/14323"&gt;@ShelleySessoms&lt;/a&gt;&amp;nbsp;may help you letting you know if there are discounts by SAS press. I vaguely remember there was a huge discount a few months ago but lasted only a couple of days though. But I have a paid &lt;STRONG&gt;safarionline&lt;/STRONG&gt; subscription anyway so it didn't matter to me.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 16:57:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Grouping-Data/m-p/516414#M3155</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-27T16:57:41Z</dc:date>
    </item>
  </channel>
</rss>

