LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2011, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 27 Jul 2011 10:05:16 -0500
Reply-To:   "Data _null_;" <iebupdte@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Data _null_;" <iebupdte@GMAIL.COM>
Subject:   Re: Top 5 and All Other
Comments:   To: "Adams, Nicholas" <NRAdams@cvty.com>
In-Reply-To:   <AD4D009B201C104A87056D05DAEA2C1DD1EB2D@AZPH-SRV-MAIL09.cvty.com>
Content-Type:   text/plain; charset=ISO-8859-1

I like to summarize using SAS procedures. If you want the top 5 frequencies you should consider ties.

proc summary data=sashelp.class nway; class name / order=freq; freq weight; output; run; proc print; run; proc rank descending; var _freq_; ranks grp; run; data; set; by grp; if first.grp and N le 5 then n + 1; if n gt 5 then name='Other'; run; proc print; run; proc freq order=data; tables name; weight _freq_; run;

On Wed, Jul 27, 2011 at 7:23 AM, Adams, Nicholas <NRAdams@cvty.com> wrote: > Is there an easy way through proc sql or data step that I can summarize > the top 5 vendors and then group 6+ into an all other. I know I can do > an Outobs=5, but then I lose the all other. Is there a Case Statement, > or some other trick I can use? > > proc sql; > create table Summary as > select Vendor, sum(allowed) > from test.met > group by Vendor > order by allowed desc; > quit; > > > Want: > > Vendor1 1000 > Vendor2 800 > Vendor3 700 > Vendor4 400 > Vendor5 200 > All Other 2000 > > > > > > Nick > > > Email Confidentiality Notice: The information contained in this transmission is confidential, proprietary or privileged and may be subject to protection under the law, including the Health Insurance Portability and Accountability Act (HIPAA). > > The message is intended for the sole use of the individual or entity to whom it is addressed. If you are not the intended recipient, you are notified that any use, distribution or copying of the message is strictly prohibited and may subject you to criminal or civil penalties. If you received this transmission in error, please contact the sender immediately by replying to this email and delete the material from any computer. >


Back to: Top of message | Previous page | Main SAS-L page