Programming the statistical procedures from SAS

How to find 3 most frequently occurring values?

Reply
N/A
Posts: 1

How to find 3 most frequently occurring values?

Hello All,

How can I find three most frequently occurring values in my data set using SAS?

Regards,

Aleksandra

Occasional Learner
Posts: 1

Re: How to find 3 most frequently occurring values?

proc means data=sashelp.class NoPrint CharType;
   class _numeric_;
   var _numeric_;
   output out=Freq(where=(_TYPE_ in('100','010','001'))) n=;
run;

option obs=3;
proc sort
   data=Freq
   out=FreqMax;
   by descending _FREQ_;
run;
option obs=max;

Esteemed Advisor
Esteemed Advisor
Posts: 6,977

Re: How to find 3 most frequently occurring values?

Proc rank springs to mind: Base SAS(R) 9.2 Procedures Guide

Or coding it in SQL:

proc sql;

     create table WANT as

     select     VAR,

                     count(OTHER_VAR) as CNT

     from        HAVE

     group by  VAR;

quit;

Where var is the caegorisor, and other_var is the occuring variable.  Then you can just take the top x from the resulting dataset.

Ask a Question
Discussion stats
  • 2 replies
  • 255 views
  • 0 likes
  • 3 in conversation