<?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: univariate in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/univariate/m-p/100841#M21085</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Supersonic,&lt;/P&gt;&lt;P&gt;You cannot use PROC UNVIARIATE to calculate statistics on categorical variables.&lt;/P&gt;&lt;P&gt;However, PROC FREQ or PROC SQL can give you this information:&lt;/P&gt;&lt;P&gt;proc freq data = sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp; table sex;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ods output OneWayFreqs = my_count;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;*in this case the 'mode' will be sex= M, since it has the highest number of occurrences?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select sex from (select sex, count(1) as count_sex from sashelp.class group&lt;/P&gt;&lt;P&gt;by sex)&lt;/P&gt;&lt;P&gt;having count_sex = max(count_sex);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....oh,well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Aug 2013 12:15:43 GMT</pubDate>
    <dc:creator>AncaTilea</dc:creator>
    <dc:date>2013-08-05T12:15:43Z</dc:date>
    <item>
      <title>univariate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/univariate/m-p/100840#M21084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;how to calculate the mode, frequency of mode and no:of distinct categories of all character variables in a dataset.&lt;/P&gt;&lt;P&gt;Prefer proc univariate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 11:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/univariate/m-p/100840#M21084</guid>
      <dc:creator>supersonic</dc:creator>
      <dc:date>2013-08-05T11:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: univariate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/univariate/m-p/100841#M21085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Supersonic,&lt;/P&gt;&lt;P&gt;You cannot use PROC UNVIARIATE to calculate statistics on categorical variables.&lt;/P&gt;&lt;P&gt;However, PROC FREQ or PROC SQL can give you this information:&lt;/P&gt;&lt;P&gt;proc freq data = sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp; table sex;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ods output OneWayFreqs = my_count;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;*in this case the 'mode' will be sex= M, since it has the highest number of occurrences?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select sex from (select sex, count(1) as count_sex from sashelp.class group&lt;/P&gt;&lt;P&gt;by sex)&lt;/P&gt;&lt;P&gt;having count_sex = max(count_sex);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....oh,well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 12:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/univariate/m-p/100841#M21085</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-08-05T12:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: univariate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/univariate/m-p/100842#M21086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the above eg will give only thetotal&amp;nbsp; frequency.&lt;/P&gt;&lt;P&gt;i need to calculate the mode, and its frequency and no:of distinct categories.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;suppose i have a list of variables in a macro list &amp;amp;list&lt;/P&gt;&lt;P&gt;so i need to claculate the mode for all variables in that list.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 12:51:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/univariate/m-p/100842#M21086</guid>
      <dc:creator>supersonic</dc:creator>
      <dc:date>2013-08-05T12:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: univariate</title>
      <link>https://communities.sas.com/t5/SAS-Programming/univariate/m-p/100843#M21087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok, it's a bit hard for me to understand the&amp;nbsp; meaning of "mode" for categorical variables. So, what about this:&lt;/P&gt;&lt;P&gt;DATA TEMP;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SET SASHELP.CLASS;&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF NAME = "Janet" THEN NAME = "Jane";&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF NAME = "James" THEN NAME = "Jane";&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF . &amp;lt;AGE &amp;lt; 12 THEN AGE_GRP = "&amp;lt; 12 yrs&amp;nbsp; ";&lt;/P&gt;&lt;P&gt;&amp;nbsp; ELSE IF 12 &amp;lt;= AGE &amp;lt;= 13 THEN AGE_GRP = "12-13 yrs";&lt;/P&gt;&lt;P&gt;&amp;nbsp; ELSE AGE_GRP = "&amp;gt; 13 yrs";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC FREQ DATA = TEMP;&lt;/P&gt;&lt;P&gt;&amp;nbsp; TABLES SEX AGE_GRP;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ODS OUTPUT ONEWAYFREQS = MY_F(KEEP = F_: FREQUENCY);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;PROC UNIVARIATE DATA = MY_F;&lt;/P&gt;&lt;P&gt;&amp;nbsp; VAR FREQUENCY;&lt;/P&gt;&lt;P&gt;&amp;nbsp; WHERE F_AGE_GRP NE " ";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;PROC UNIVARIATE DATA = MY_F;&lt;/P&gt;&lt;P&gt;&amp;nbsp; VAR FREQUENCY;&lt;/P&gt;&lt;P&gt;&amp;nbsp; WHERE F_SEX NE " ";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the first step, I modify the data SASHELP.CLASS to create another categorical variable, age_grp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you run a frequency for the categorical variables...output a data set that will give you &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;no:of distinct categories.&lt;/SPAN&gt; Then run a univariate on it...and you get the mode (if it exists)...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 13:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/univariate/m-p/100843#M21087</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-08-05T13:18:37Z</dc:date>
    </item>
  </channel>
</rss>

