<?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 is the difference between Class and by statement in PROC MEANS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128373#M260397</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The class statement is fantastic for getting subtotals as well as totals in an output dataset (proc summary == proc means noprint) - using the Descending option puts the grand total last. &lt;/P&gt;&lt;P&gt;Saves having to do a sort first&lt;/P&gt;&lt;P&gt;BUT - big but - all the class running totals have to be held in memory (at least in earlier versions) which can be a problem if you have multiple class variables with many levels each.&amp;nbsp; If you run out of memory you may have to resort to sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 May 2013 11:31:05 GMT</pubDate>
    <dc:creator>RichardinOz</dc:creator>
    <dc:date>2013-05-03T11:31:05Z</dc:date>
    <item>
      <title>What is the difference between Class and by statement in PROC MEANS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128369#M260393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to know the difference between the CLASS statement and BY statement in PROC MEANS, could anyone clarify for me?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 21:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128369#M260393</guid>
      <dc:creator>Jack2012</dc:creator>
      <dc:date>2013-05-02T21:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: What is the difference between Class and by statement in PROC MEANS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128370#M260394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would look in the online documentation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 21:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128370#M260394</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-05-02T21:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: What is the difference between Class and by statement in PROC MEANS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128371#M260395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I checked in the SAS guide, but still can't get an easily answer to this question. Hope you can explain in an easy-understand way. Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 May 2013 01:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128371#M260395</guid>
      <dc:creator>Jack2012</dc:creator>
      <dc:date>2013-05-03T01:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: What is the difference between Class and by statement in PROC MEANS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128372#M260396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CLASS and BY statements have similar effects but there are some subtle differences. In the documentation it says:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 14pt;"&gt;&lt;STRONG&gt;Comparison of the BY and CLASS Statements&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Using the BY statement is similar to using the CLASS statement and the NWAY option in that PROC MEANS summarizes each BY group as an independent subset of the input data. Therefore, no overall summarization of the input data is available. However, unlike the CLASS statement, the BY statement requires that you previously sort BY variables. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;When you use the NWAY option, PROC MEANS might encounter insufficient memory for the summarization of all the class variables. You can move some class variables to the BY statement. For maximum benefit, move class variables to the BY statement that are already sorted or that have the greatest number of unique values. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;You can use the CLASS and BY statements together to analyze the data by the levels of class variables within BY groups.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Practically, this means that:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt; &lt;BR /&gt;The input dataset must be sorted by the BY variables. It doesn't have to be sorted by the CLASS variables.&lt;/LI&gt;&lt;LI&gt; &lt;BR /&gt;Without the NWAY option in the PROC MEANS statement, the CLASS statement will calculate summaries for each class variable separately as well as for each possible combination of class variables. The BY statement only provides summaries for the groups created by the combination of all BY variables.&lt;/LI&gt;&lt;LI&gt; &lt;BR /&gt;The BY summaries are reported in separate tables (pages) whereas the CLASS summaries appear in a single table.&lt;/LI&gt;&lt;LI&gt; &lt;BR /&gt;The MEANS procedure is more efficient at treating BY groups than CLASS groups.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check out the example&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#p074ebrvnxe5yan1ii4rykkqp3o9.htm" title="http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#p074ebrvnxe5yan1ii4rykkqp3o9.htm"&gt;Base SAS(R) 9.3 Procedures Guide, Second Edition&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I find it quite informative.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 May 2013 01:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128372#M260396</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-05-03T01:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: What is the difference between Class and by statement in PROC MEANS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128373#M260397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The class statement is fantastic for getting subtotals as well as totals in an output dataset (proc summary == proc means noprint) - using the Descending option puts the grand total last. &lt;/P&gt;&lt;P&gt;Saves having to do a sort first&lt;/P&gt;&lt;P&gt;BUT - big but - all the class running totals have to be held in memory (at least in earlier versions) which can be a problem if you have multiple class variables with many levels each.&amp;nbsp; If you run out of memory you may have to resort to sort.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 May 2013 11:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128373#M260397</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-05-03T11:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: What is the difference between Class and by statement in PROC MEANS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128374#M260398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As PG points out, "The BY summaries are reported in separate tables (pages) whereas the CLASS summaries appear in a single table."&lt;/P&gt;&lt;P&gt;To me, this is the biggest difference.&amp;nbsp; If I want to compare statistics across categories (such as male/female), I will use the CLASS statement when I want one table that contains all of the statistics (which is most of the time).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 May 2013 12:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128374#M260398</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-05-03T12:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: What is the difference between Class and by statement in PROC MEANS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128375#M260399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As &lt;A __default_attr="129106" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; said, when comparing stats I usually go for the CLASS statement.&amp;nbsp; As others have pointed out, BY requires the input data to be sorted.&amp;nbsp; However, if your input data is coming from a database library (and not a SAS data set), PROC MEANS is smart enough to ask for the data in "sorted" order before calculating the stats, so a separate PROC SORT step is not necessary.&amp;nbsp; In fact, with SAS 9.2 and later, PROC MEANS will actually get the database to calculate the basic stats if it can: Avg, Sum, Min, Max and so on -- thus saving lots of I/O within your SAS session.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other "database-aware" procs include FREQ, RANK, SUMMARY/MEANS, REPORT, TABULATE.&amp;nbsp; See &lt;A href="http://support.sas.com/kb/43/144.html"&gt;this SAS Note for more information&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 May 2013 13:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-difference-between-Class-and-by-statement-in-PROC/m-p/128375#M260399</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2013-05-03T13:12:44Z</dc:date>
    </item>
  </channel>
</rss>

