<?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 Re: add Cardinality Ratio to output from proc.freq.nlevels; in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/add-Cardinality-Ratio-to-output-from-proc-freq-nlevels/m-p/198081#M49486</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is your question ? you have different version of solution&amp;nbsp; .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Jun 2015 13:05:07 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2015-06-03T13:05:07Z</dc:date>
    <item>
      <title>add Cardinality Ratio to output from proc.freq.nlevels;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/add-Cardinality-Ratio-to-output-from-proc-freq-nlevels/m-p/198080#M49485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;... and JMP, while we are at it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written several papers on Cardinality Ratio and have an sco wiki page on it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/Cardinality_Ratio" title="http://www.sascommunity.org/wiki/Cardinality_Ratio"&gt;http://www.sascommunity.org/wiki/Cardinality_Ratio&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;definitions:&lt;/P&gt;&lt;P&gt;* the cardinality of a set is the number of elements in the set&lt;/P&gt;&lt;P&gt;* cardinality of a data set is n-obs&lt;/P&gt;&lt;P&gt;* cardinality of a variable is n-levels&lt;/P&gt;&lt;P&gt;* cardinality ratio is n-levels / n-obs;&lt;/P&gt;&lt;P&gt;* CR is a reducing function, its range is in (0:1]&lt;/P&gt;&lt;P&gt;and it is easier to compare variable's CR than the range of n-levels in (1:n-obs)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if one takes the time to calculate the n-levels of each variable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data = sashelp.class nlevels;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know you have the n-obs of the data set,&lt;/P&gt;&lt;P&gt;so, in my book it is a simple step to calculate &lt;/P&gt;&lt;P&gt;cardinality_ratio = n-levels / n-obs;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why is this a Good Idea?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because it takes several steps to calculate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc contents ... out = out_contents;&lt;/P&gt;&lt;P&gt;proc freq ... out= out_freq;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort out_contents&lt;/P&gt;&lt;P&gt;proc sort out_freq&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data cardinality_ratio;&lt;/P&gt;&lt;P&gt;merge out_contents out_freq; &lt;/P&gt;&lt;P&gt;by name;&lt;/P&gt;&lt;P&gt;cardinality_ratio = nlevels / nobs;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc summary var cardinality_ratio out = out_means&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data cr_type;&lt;/P&gt;&lt;P&gt;select;&lt;/P&gt;&lt;P&gt;when ... cr_type = 'unique';&lt;/P&gt;&lt;P&gt;when ... cr_type = 'many';&lt;/P&gt;&lt;P&gt;otherwise cr_type = 'few';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having proc freq do the number-crunching makes calculating the &lt;/P&gt;&lt;P&gt;cr-type in (continuous, discrete, unique)&lt;/P&gt;&lt;P&gt;easier.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 16:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/add-Cardinality-Ratio-to-output-from-proc-freq-nlevels/m-p/198080#M49485</guid>
      <dc:creator>Ron_MacroMaven</dc:creator>
      <dc:date>2015-06-02T16:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: add Cardinality Ratio to output from proc.freq.nlevels;</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/add-Cardinality-Ratio-to-output-from-proc-freq-nlevels/m-p/198081#M49486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is your question ? you have different version of solution&amp;nbsp; .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jun 2015 13:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/add-Cardinality-Ratio-to-output-from-proc-freq-nlevels/m-p/198081#M49486</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-06-03T13:05:07Z</dc:date>
    </item>
  </channel>
</rss>

