BookmarkSubscribeRSS Feed
Ola22
Calcite | Level 5

Hello All,

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

Regards,

Aleksandra

2 REPLIES 2
craftsman
Calcite | Level 5

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;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1353 views
  • 0 likes
  • 3 in conversation