<?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 Export NLEVELS from PROC FREQ to a DataSet in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Export-NLEVELS-from-PROC-FREQ-to-a-DataSet/m-p/473579#M21171</link>
    <description>&lt;P&gt;Hi Guys&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So this is the situation I have a bunch of tables that i need&lt;FONT face="helvetica"&gt; to bring&lt;/FONT&gt; all of their variables and pull all the different values they can hold so i made this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;proc contents data=xxx out=yyy (keep=name); run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;proc sql noprint; select count(*) into : maxvar separated by 'anything' from yyy; quit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%macro loop;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;%do i = 1 %to &amp;amp;maxvar.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; data _null_; set yyy; if _n_ = &amp;amp;i. then call symput ("var", compress(name)); run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#0000FF"&gt;proc freq data = yyy nlevels; tables &amp;amp;var. / noprint; run;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;%end;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%mend; %loop;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="helvetica"&gt;Im doing it one by one since there are some previous filters applied to the list of variables to pull their levels. If i do an &lt;FONT face="courier new,courier" color="#0000FF"&gt;out = zzz&amp;nbsp;&lt;FONT face="helvetica" color="#000000"&gt;this will bring a list of all the values and their percentage, i dont need that i just need a dataset with the levels of the varariable so then i can concatenate them into a single dataset.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jun 2018 01:55:26 GMT</pubDate>
    <dc:creator>BernyOsuna</dc:creator>
    <dc:date>2018-06-27T01:55:26Z</dc:date>
    <item>
      <title>Export NLEVELS from PROC FREQ to a DataSet</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Export-NLEVELS-from-PROC-FREQ-to-a-DataSet/m-p/473579#M21171</link>
      <description>&lt;P&gt;Hi Guys&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So this is the situation I have a bunch of tables that i need&lt;FONT face="helvetica"&gt; to bring&lt;/FONT&gt; all of their variables and pull all the different values they can hold so i made this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;proc contents data=xxx out=yyy (keep=name); run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;proc sql noprint; select count(*) into : maxvar separated by 'anything' from yyy; quit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%macro loop;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;%do i = 1 %to &amp;amp;maxvar.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; data _null_; set yyy; if _n_ = &amp;amp;i. then call symput ("var", compress(name)); run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#0000FF"&gt;proc freq data = yyy nlevels; tables &amp;amp;var. / noprint; run;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;%end;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%mend; %loop;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="helvetica"&gt;Im doing it one by one since there are some previous filters applied to the list of variables to pull their levels. If i do an &lt;FONT face="courier new,courier" color="#0000FF"&gt;out = zzz&amp;nbsp;&lt;FONT face="helvetica" color="#000000"&gt;this will bring a list of all the values and their percentage, i dont need that i just need a dataset with the levels of the varariable so then i can concatenate them into a single dataset.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 01:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Export-NLEVELS-from-PROC-FREQ-to-a-DataSet/m-p/473579#M21171</guid>
      <dc:creator>BernyOsuna</dc:creator>
      <dc:date>2018-06-27T01:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Export NLEVELS from PROC FREQ to a DataSet</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Export-NLEVELS-from-PROC-FREQ-to-a-DataSet/m-p/473583#M21172</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'm not sure you need a macro process unless you want something more complicated than this. The name of the output object for NLEVELS is very sensibly named "NLEVELS" so you can use an ODS OUTPUT statement to get the NLEVELS for all the variables into 1 datastep with one PROC FREQ step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output nlevels=work.nlev_all;
proc freq data=sashelp.shoes nlevels;
  tables _all_;
run;

proc print data=work.nlev_all;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;produces this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nlevels_shoes.png" style="width: 377px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21428iA98F036D8E954BED/image-size/large?v=v2&amp;amp;px=999" role="button" title="nlevels_shoes.png" alt="nlevels_shoes.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, you might not want to get the levels on the numeric variables, in which case you could change the dataset to have&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;tables _character_;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you just wanted character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 02:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Export-NLEVELS-from-PROC-FREQ-to-a-DataSet/m-p/473583#M21172</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-06-27T02:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Export NLEVELS from PROC FREQ to a DataSet</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Export-NLEVELS-from-PROC-FREQ-to-a-DataSet/m-p/473592#M21174</link>
      <description>&lt;P&gt;If you don't want to actually print the frequencies, just get the number of levels, then add the /NOPRINT option to the TABLES statement.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 04:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Export-NLEVELS-from-PROC-FREQ-to-a-DataSet/m-p/473592#M21174</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-27T04:00:14Z</dc:date>
    </item>
  </channel>
</rss>

