<?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: What exactly is nlevels? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/474530#M121936</link>
    <description>&lt;P&gt;&lt;SPAN class=" aa-term "&gt;Documentation is pretty thorough here IMO:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=" aa-term "&gt;NLEVELS&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A id="procstat.freq.a0000000025" class="indexterm" target="_blank"&gt;&lt;/A&gt;&lt;A id="procstat.freq.a0000000026" class="indexterm" target="_blank"&gt;&lt;/A&gt;displays the "Number of Variable Levels" table, &lt;STRONG&gt;which provides the number of levels for each variable named in the TABLES statements&lt;/STRONG&gt;. For more information, see the section&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="ng-scope" tabindex="0" href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_details111.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#procstat.freq.freqdnlevels" rel="nofollow" data-docset-id="procstat" data-docset-version="9.4" data-original-href="procstat_freq_details111.htm#procstat.freq.freqdnlevels"&gt;Number of Variable Levels Table&lt;/A&gt;. &lt;STRONG&gt;PROC FREQ determines the variable levels from the formatted variable values&lt;/STRONG&gt;, as described in the section&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="ng-scope" tabindex="0" href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_details02.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" rel="nofollow" data-docset-id="procstat" data-docset-version="9.4" data-original-href="procstat_freq_details02.htm"&gt;Grouping with Formats&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_syntax01.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#procstat.freq.freqnlevels" target="_self"&gt;Source&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;H4 class="xis-title"&gt;Number of Variable Levels Table&lt;/H4&gt;
&lt;/DIV&gt;
&lt;P&gt;If you specify the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="ng-scope" tabindex="0" href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_syntax01.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#procstat.freq.freqnlevels" rel="nofollow" data-docset-id="procstat" data-docset-version="9.4" data-original-href="procstat_freq_syntax01.htm#procstat.freq.freqnlevels"&gt;NLEVELS&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;option in the PROC FREQ statement, PROC FREQ displays the "Number of Variable Levels" table. This table provides the number of levels for all variables named in the TABLES statements. PROC FREQ determines the variable levels from the formatted variable values. For more information, see the section&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="ng-scope" tabindex="0" href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_details02.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" rel="nofollow" data-docset-id="procstat" data-docset-version="9.4" data-original-href="procstat_freq_details02.htm"&gt;Grouping with Formats&lt;/A&gt;. The "Number of Variable Levels" table contains the following information:&lt;/P&gt;
&lt;DIV&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Variable name&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Levels, which is the total number of levels of the variable&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Number of Nonmissing Levels, if there are missing levels for any of the variables&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Number of Missing Levels, if there are missing levels for any of the variables&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_details111.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#procstat.freq.freqdnlevels" target="_self"&gt;Source&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Translation:&lt;/P&gt;
&lt;P&gt;It gives you the number of unique levels of a variable, for example in SASHELP.CLASS, the variable SEX has 2 different unique values, while Age has XXX.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jun 2018 17:52:08 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-06-29T17:52:08Z</dc:date>
    <item>
      <title>What exactly is nlevels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/474520#M121932</link>
      <description>&lt;P&gt;Could someone provide a little more color. I know that it is an option in proc freq, but i am not really clear on its usefulness and what exactly it is. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 17:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/474520#M121932</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2018-06-29T17:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: What exactly is nlevels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/474530#M121936</link>
      <description>&lt;P&gt;&lt;SPAN class=" aa-term "&gt;Documentation is pretty thorough here IMO:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=" aa-term "&gt;NLEVELS&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A id="procstat.freq.a0000000025" class="indexterm" target="_blank"&gt;&lt;/A&gt;&lt;A id="procstat.freq.a0000000026" class="indexterm" target="_blank"&gt;&lt;/A&gt;displays the "Number of Variable Levels" table, &lt;STRONG&gt;which provides the number of levels for each variable named in the TABLES statements&lt;/STRONG&gt;. For more information, see the section&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="ng-scope" tabindex="0" href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_details111.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#procstat.freq.freqdnlevels" rel="nofollow" data-docset-id="procstat" data-docset-version="9.4" data-original-href="procstat_freq_details111.htm#procstat.freq.freqdnlevels"&gt;Number of Variable Levels Table&lt;/A&gt;. &lt;STRONG&gt;PROC FREQ determines the variable levels from the formatted variable values&lt;/STRONG&gt;, as described in the section&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="ng-scope" tabindex="0" href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_details02.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" rel="nofollow" data-docset-id="procstat" data-docset-version="9.4" data-original-href="procstat_freq_details02.htm"&gt;Grouping with Formats&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_syntax01.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#procstat.freq.freqnlevels" target="_self"&gt;Source&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;H4 class="xis-title"&gt;Number of Variable Levels Table&lt;/H4&gt;
&lt;/DIV&gt;
&lt;P&gt;If you specify the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="ng-scope" tabindex="0" href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_syntax01.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#procstat.freq.freqnlevels" rel="nofollow" data-docset-id="procstat" data-docset-version="9.4" data-original-href="procstat_freq_syntax01.htm#procstat.freq.freqnlevels"&gt;NLEVELS&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;option in the PROC FREQ statement, PROC FREQ displays the "Number of Variable Levels" table. This table provides the number of levels for all variables named in the TABLES statements. PROC FREQ determines the variable levels from the formatted variable values. For more information, see the section&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A class="ng-scope" tabindex="0" href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_details02.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" rel="nofollow" data-docset-id="procstat" data-docset-version="9.4" data-original-href="procstat_freq_details02.htm"&gt;Grouping with Formats&lt;/A&gt;. The "Number of Variable Levels" table contains the following information:&lt;/P&gt;
&lt;DIV&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Variable name&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Levels, which is the total number of levels of the variable&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Number of Nonmissing Levels, if there are missing levels for any of the variables&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Number of Missing Levels, if there are missing levels for any of the variables&lt;/STRONG&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=procstat&amp;amp;docsetTarget=procstat_freq_details111.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#procstat.freq.freqdnlevels" target="_self"&gt;Source&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Translation:&lt;/P&gt;
&lt;P&gt;It gives you the number of unique levels of a variable, for example in SASHELP.CLASS, the variable SEX has 2 different unique values, while Age has XXX.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 17:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/474530#M121936</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-29T17:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: What exactly is nlevels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/474572#M121950</link>
      <description>&lt;P&gt;One use is to compare expected numbers of responses to a variable. See the following example:&lt;/P&gt;
&lt;PRE&gt;ods select nlevels;
proc freq data=sashelp.class  nlevels;
ods output nlevels=work.classlevels;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which creates in the results window&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" cellspacing="0" cellpadding="3" summary="Procedure Freq: NLevels"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c m header" colspan="2" scope="colgroup"&gt;Number of Variable&lt;BR /&gt;Levels&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m header" scope="col"&gt;Variable&lt;/TH&gt;
&lt;TH class="c m header" scope="col"&gt;Levels&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Name&lt;/TH&gt;
&lt;TD class="r data"&gt;19&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Sex&lt;/TH&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Age&lt;/TH&gt;
&lt;TD class="r data"&gt;6&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Height&lt;/TH&gt;
&lt;TD class="r data"&gt;17&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l m rowheader" scope="row"&gt;Weight&lt;/TH&gt;
&lt;TD class="r data"&gt;15&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if "knew" I have 19 records and expect 19 unique names then I don't have to examine the actual values (somewhat useful for identifying the presence of duplicates when you have 1000's of records). If I had expected two levels of Sex and something like 8 I would suspect something wrong.&lt;/P&gt;
&lt;P&gt;This rough information could also be used to select or reduce variables for examination with the full Proc Freq output (run without the ODS Select just preceding).&lt;/P&gt;
&lt;P&gt;I often run Proc Freq on data sets as an initial data check. BUT if I have 1000's of records and may have some variables that seldom or don't duplicate such as name, phone number, account number and similar then I can reduce the proc freq output by examining the Nlevels and then run something like&lt;/P&gt;
&lt;P&gt;Proc freq data=have(drop=name phone account);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;to get tables of the values other than those variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output data set created with the ods output statement also has additional information about missing levels. Which if you don't expect any missing values for a variable and have NMissLevels greater than 0 you have at least one missing value. If you use the special missing values .A to .Z in addition to . then the NMissLevels variable will indicate how many have been used. If you don't think you were using special missing and see a value greater than 1 that tells you that assumption was incorrect.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 20:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/474572#M121950</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-29T20:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: What exactly is nlevels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/474658#M121975</link>
      <description>&lt;P&gt;If you were familiar with SQL. it is the same thing as :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select count(distinct sex) as nlevels
 from sashelp.class;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Jun 2018 11:42:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/474658#M121975</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-06-30T11:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: What exactly is nlevels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/658048#M197204</link>
      <description>&lt;P&gt;I had the same question. I guess I'm confused about the word "level" being used in this context. The English word "level" means a layer of a building (e.g. Ground level) or a rank in scale or size (e.g. at national/international level) or a tool that tests whether a surface is flat (i.e. a spirit level). Does the term "number of variable levels" depict rankings/layers of the variable of interest? Or does it just mean: a list of values of a variable?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 12:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/658048#M197204</guid>
      <dc:creator>drpartonslab</dc:creator>
      <dc:date>2020-06-12T12:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: What exactly is nlevels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/658050#M197205</link>
      <description>&lt;P&gt;As explained above, NLEVELS is the number of distinct values of a variable. In SASHELP.CLASS, NLEVELS=2 for variable SEX and NLEVELS=17 for variable HEIGHT.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 12:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/658050#M197205</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-12T12:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: What exactly is nlevels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/826438#M326443</link>
      <description>&lt;P&gt;I think the documentation here is lacking. What is really needed is a definition of the word "levels": one might infere it but, since it's quite easy to come up with a robust one, it should be added into the official documentation. For example "A level of a variable is one of the unique values that such variable assumes in the dataset".&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 13:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/826438#M326443</guid>
      <dc:creator>MikeFox</dc:creator>
      <dc:date>2022-08-01T13:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: What exactly is nlevels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/826439#M326444</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/420040"&gt;@MikeFox&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I think the documentation here is lacking. What is really needed is a definition of the word "levels": one might infere it but, since it's quite easy to come up with a robust one, it should be added into the official documentation. For example "A level of a variable is one of the unique values that such variable assumes in the dataset".&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Earlier in this thread, someone discussed the meaning of "level" according to the English language. However that's irrelevant here, level has a meaning in statistical language that doesn't have to correspond to English dictionary meanings of the word, and it is exactly what you say.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 13:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/826439#M326444</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-08-01T13:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: What exactly is nlevels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/828049#M327093</link>
      <description>&lt;P&gt;I wasn't aware of this. My guess is that SAS being born as a tool for people with a strong background in statistics the definition of levels is assumed to be well known, and it would have been redundant to have it added into the documentation. However, since SAS has grown and expanded to reach people with a more diverse background I still think it wouldn't hurt to add a reminder. Thanks for the clarification.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 10:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-exactly-is-nlevels/m-p/828049#M327093</guid>
      <dc:creator>MikeFox</dc:creator>
      <dc:date>2022-08-10T10:02:59Z</dc:date>
    </item>
  </channel>
</rss>

