<?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 How to get a quick view of the categories for all the categorial variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57150#M15950</link>
    <description>I just got a very large SAS data. Most of the variables are categorical. I need to get a summary of the different categories for each of the categorical variables. How can I do this? I tried PROC Contents but it does not show all the categories.</description>
    <pubDate>Tue, 26 Apr 2011 09:50:28 GMT</pubDate>
    <dc:creator>bncoxuk</dc:creator>
    <dc:date>2011-04-26T09:50:28Z</dc:date>
    <item>
      <title>How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57150#M15950</link>
      <description>I just got a very large SAS data. Most of the variables are categorical. I need to get a summary of the different categories for each of the categorical variables. How can I do this? I tried PROC Contents but it does not show all the categories.</description>
      <pubDate>Tue, 26 Apr 2011 09:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57150#M15950</guid>
      <dc:creator>bncoxuk</dc:creator>
      <dc:date>2011-04-26T09:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57151#M15951</link>
      <description>What categories do you mean?&lt;BR /&gt;
If you can find something in proc contents. Maybe dictionary table dictionary.columns woule contains some information you need.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 26 Apr 2011 10:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57151#M15951</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-26T10:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57152#M15952</link>
      <description>Suppose I have a variable called 'brands'. This variable has 8 categories (e.g. Kraft, Cadbury). Another variable called 'products'. This variable has 3 categories (e.g. Food). In the dataset, there are over 50 variables, each of which has a set of categories.&lt;BR /&gt;
&lt;BR /&gt;
 I want to get a summary of the categories that each of the variables have.</description>
      <pubDate>Tue, 26 Apr 2011 10:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57152#M15952</guid>
      <dc:creator>bncoxuk</dc:creator>
      <dc:date>2011-04-26T10:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57153#M15953</link>
      <description>The quick simple view would be PROC FREQ.&lt;BR /&gt;
If you leave out a table statement you'll get output for all variables in the data.&lt;BR /&gt;
Use the NLEVELS option as &lt;BR /&gt;
Proc freq data=&lt;YOUR data="https://communities.sas.com/" set="" name="" here=""&gt; nlevels;run;&lt;BR /&gt;
&lt;BR /&gt;
This generates a table of variable names, labels and how many levels (categories) a variable may have. Large numbers would indicate things that aren't likely to be "categories" in the way you are thinking.&lt;/YOUR&gt;</description>
      <pubDate>Tue, 26 Apr 2011 17:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57153#M15953</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-04-26T17:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57154#M15954</link>
      <description>Yes.&lt;BR /&gt;
ballarwd is right.Try it.the dataset want_dataset contains the information you want.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods output nlevels=want_dataset;&lt;BR /&gt;
proc freq data=sashelp.class nlevels;&lt;BR /&gt;
 tables _all_;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 27 Apr 2011 00:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57154#M15954</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-27T00:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57155#M15955</link>
      <description>ballardw,&lt;BR /&gt;
&lt;BR /&gt;
I tried, but this only gave me the number of levels each variable has. In fact, what i want to find out is the names of all the levels, not just 'how many levels'. Thank you.</description>
      <pubDate>Wed, 27 Apr 2011 04:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57155#M15955</guid>
      <dc:creator>bncoxuk</dc:creator>
      <dc:date>2011-04-27T04:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57156#M15956</link>
      <description>Ksharp, I am looking for the names of all the levels, not just 'how many levels'. &lt;BR /&gt;
&lt;BR /&gt;
Thanks for help.</description>
      <pubDate>Wed, 27 Apr 2011 04:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57156#M15956</guid>
      <dc:creator>bncoxuk</dc:creator>
      <dc:date>2011-04-27T04:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57157#M15957</link>
      <description>Oh.&lt;BR /&gt;
You need this.&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods output onewayfreqs=want;&lt;BR /&gt;
proc freq data=sashelp.class ;&lt;BR /&gt;
 tables _all_ ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 27 Apr 2011 09:44:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57157#M15957</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-27T09:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57158#M15958</link>
      <description>Ksharp, I tried again, but the code you gave to me only products a cummulative frequency etc. for a continuous (numeric) variable. The results do not show anything about the categorical variables.&lt;BR /&gt;
&lt;BR /&gt;
To put the question simple, I want to get a summary table which shows the names of the levels for all the categorical variables. For example, the variable Gender has 3 levels (M, F, O), and the variable AgeGroup has 5 groups (1, 2, 3, 4, 5). I want to get a table to show the levels for all such categorical variables.&lt;BR /&gt;
&lt;BR /&gt;
The question seems very easy, but in practice very difficult to get an easy solution.</description>
      <pubDate>Wed, 27 Apr 2011 12:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57158#M15958</guid>
      <dc:creator>bncoxuk</dc:creator>
      <dc:date>2011-04-27T12:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57159#M15959</link>
      <description>Hello Bncohuk,&lt;BR /&gt;
&lt;BR /&gt;
This is my solution for SASHELP.CLASS:&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc SQL;&lt;BR /&gt;
  select COUNT(distinct Name) as n into :n&lt;BR /&gt;
  from sashelp.vcolumn &lt;BR /&gt;
  where libname="SASHELP" and memname="CLASS";&lt;BR /&gt;
  %let n=%trim(&amp;amp;n);&lt;BR /&gt;
  select distinct name as name into :n1-:n&amp;amp;n&lt;BR /&gt;
  from sashelp.vcolumn &lt;BR /&gt;
  where libname="SASHELP" and memname="CLASS";&lt;BR /&gt;
;quit;&lt;BR /&gt;
%macro a;&lt;BR /&gt;
  %do i=1 %to &amp;amp;n;&lt;BR /&gt;
     proc SQL;&lt;BR /&gt;
     create table _t as &lt;BR /&gt;
       select distinct &amp;amp;&amp;amp;n&amp;amp;i&lt;BR /&gt;
       from SASHELP.CLASS &lt;BR /&gt;
     ;quit;&lt;BR /&gt;
     %if &amp;amp;i = 1 %then %do; data r; set     _t; run; %end;&lt;BR /&gt;
     %else            %do; data r; merge r _t; run; %end;&lt;BR /&gt;
  %end;&lt;BR /&gt;
%mend a;&lt;BR /&gt;
%a; &lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Wed, 27 Apr 2011 13:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57159#M15959</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-04-27T13:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57160#M15960</link>
      <description>&amp;gt; ballardw,&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I tried, but this only gave me the number of levels&lt;BR /&gt;
&amp;gt; each variable has. In fact, what i want to find out&lt;BR /&gt;
&amp;gt; is the names of all the levels, not just 'how many&lt;BR /&gt;
&amp;gt; levels'. Thank you.&lt;BR /&gt;
&lt;BR /&gt;
Use the list of varialbles that look likely to be categories in Proc Freq.&lt;BR /&gt;
&lt;BR /&gt;
You could just use Proc Freq data=yourdata;run;&lt;BR /&gt;
BUT if you have identification variables (which are categorical), phone numbers and such as well as any continuous or pseudocontinuous (income for examp) but don't want to see every one of those you need a way to find the likely ones of interest. That's what the levels statement does in this case, give a starting point.&lt;BR /&gt;
&lt;BR /&gt;
I'd be tempted to dump the levels output to a dataset and filter on the range of levels to get a list of variable for use elsewhere.</description>
      <pubDate>Wed, 27 Apr 2011 17:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57160#M15960</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-04-27T17:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57161#M15961</link>
      <description>Yes.I gave you an answer.But you need to process this dataset.&lt;BR /&gt;
OK. let me to giva you a solution.try this:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods output onewayfreqs=want(drop=frequency);&lt;BR /&gt;
proc freq data=sashelp.class ;&lt;BR /&gt;
 tables _all_ /nopercent nocum nofreq ;&lt;BR /&gt;
run;&lt;BR /&gt;
data want;&lt;BR /&gt;
 set want;&lt;BR /&gt;
 variable_name=scan(table,2);&lt;BR /&gt;
 variable_value=scan(catx(' ',of name -- weight),1);&lt;BR /&gt;
 keep variable_:;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Opps.NOTE: name is your first variable and weight is your last variable in dataset.&lt;BR /&gt;
Ksharp

Message was edited by: Ksharp</description>
      <pubDate>Thu, 28 Apr 2011 01:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57161#M15961</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-28T01:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57162#M15962</link>
      <description>SPR, you approach gave me all the variable names in the data set. So I used the one by KSharp which worked.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Thu, 28 Apr 2011 05:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57162#M15962</guid>
      <dc:creator>bncoxuk</dc:creator>
      <dc:date>2011-04-28T05:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a quick view of the categories for all the categorial variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57163#M15963</link>
      <description>Hello Bncoxuk,&lt;BR /&gt;
&lt;BR /&gt;
Dataset r in my program contains the information you requested and it is the same as in KSHARP's output but does not contain counts.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Thu, 28 Apr 2011 13:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-get-a-quick-view-of-the-categories-for-all-the-categorial/m-p/57163#M15963</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-04-28T13:29:11Z</dc:date>
    </item>
  </channel>
</rss>

