BookmarkSubscribeRSS Feed
Ron_MacroMaven
Lapis Lazuli | Level 10

... and JMP, while we are at it.

I have written several papers on Cardinality Ratio and have an sco wiki page on it.

http://www.sascommunity.org/wiki/Cardinality_Ratio

definitions:

* the cardinality of a set is the number of elements in the set

* cardinality of a data set is n-obs

* cardinality of a variable is n-levels

* cardinality ratio is n-levels / n-obs;

* CR is a reducing function, its range is in (0:1]

and it is easier to compare variable's CR than the range of n-levels in (1:n-obs)

if one takes the time to calculate the n-levels of each variable

proc freq data = sashelp.class nlevels;

I know you have the n-obs of the data set,

so, in my book it is a simple step to calculate

cardinality_ratio = n-levels / n-obs;

Why is this a Good Idea?

Because it takes several steps to calculate it.

proc contents ... out = out_contents;

proc freq ... out= out_freq;

proc sort out_contents

proc sort out_freq

data cardinality_ratio;

merge out_contents out_freq;

by name;

cardinality_ratio = nlevels / nobs;

proc summary var cardinality_ratio out = out_means

data cr_type;

select;

when ... cr_type = 'unique';

when ... cr_type = 'many';

otherwise cr_type = 'few';

Having proc freq do the number-crunching makes calculating the

cr-type in (continuous, discrete, unique)

easier.

1 REPLY 1
Ksharp
Super User

What is your question ? you have different version of solution  .

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 Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 698 views
  • 0 likes
  • 2 in conversation