<?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: some observations with use of class and by statement in proc means in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/some-observations-with-use-of-class-and-by-statement-in-proc/m-p/663678#M78939</link>
    <description>&lt;P&gt;You could find the reason to the issue in the log:&lt;/P&gt;
&lt;PRE&gt;ERROR: Data set WORK.SHOES is not sorted in ascending sequence. The current BY group has Product = Women's Dress and the next BY 
 group has Product = Boot.&lt;/PRE&gt;
&lt;P&gt;Add&amp;nbsp; appropriate sort before running any proc with BY statement.&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jun 2020 05:47:08 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2020-06-20T05:47:08Z</dc:date>
    <item>
      <title>some observations with use of class and by statement in proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/some-observations-with-use-of-class-and-by-statement-in-proc/m-p/663677#M78938</link>
      <description>&lt;P&gt;Hello SAS Community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Query is on use of class and by statement in proc means.&lt;/P&gt;&lt;P&gt;By and class statement is applicable for character type data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used sample data shoe in SASHELP folder and using SAS Studio.&lt;/P&gt;&lt;P&gt;region and product are the charater data I am interested in, for sales total.&lt;/P&gt;&lt;P&gt;I am interested to have result table of sales sales for each region by product and then second table for each product by region.&lt;/P&gt;&lt;P&gt;Refer attached 'proc means example.sas' file for code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to see the result table for product by region correctly, meaning all products in single table separated for/by each region.&lt;/P&gt;&lt;P&gt;while result table for region by product includes only africa region rather than all region in table seperated for/by each product.&lt;/P&gt;&lt;P&gt;Refer attached 'proc means example-results.pdf' for results table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help why is it so?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jun 2020 05:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/some-observations-with-use-of-class-and-by-statement-in-proc/m-p/663677#M78938</guid>
      <dc:creator>baystanil</dc:creator>
      <dc:date>2020-06-20T05:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: some observations with use of class and by statement in proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/some-observations-with-use-of-class-and-by-statement-in-proc/m-p/663678#M78939</link>
      <description>&lt;P&gt;You could find the reason to the issue in the log:&lt;/P&gt;
&lt;PRE&gt;ERROR: Data set WORK.SHOES is not sorted in ascending sequence. The current BY group has Product = Women's Dress and the next BY 
 group has Product = Boot.&lt;/PRE&gt;
&lt;P&gt;Add&amp;nbsp; appropriate sort before running any proc with BY statement.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jun 2020 05:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/some-observations-with-use-of-class-and-by-statement-in-proc/m-p/663678#M78939</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-06-20T05:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: some observations with use of class and by statement in proc means</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/some-observations-with-use-of-class-and-by-statement-in-proc/m-p/663861#M78947</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/324160"&gt;@baystanil&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello SAS Community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By and class statement is applicable for character type data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;CLASS and BY variables can be variables of any type. Always. It is a good idea to use them with variables that make sense as categories.&lt;/P&gt;
&lt;P&gt;It is very common to use date variables as CLASS variables because changing the format in the code will create different groups based on the formatted variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the advantages of CLASS variables is that SAS will do the sort when they are not sorted before the procedure. There is a processing time penalty and extremely large number of class variable/level combinations may exceed resources.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also consider a different procedure to generate the output since you apparently do not have a need for output data sets. Consider:&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=sashelp.shoes format=best10.;
   class region product;
   var sales;
   table region,
         sales
   ;
   table product,
         sales
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Proc tabulate will create the summaries using the formatted values of the class variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Caveat: Proc tabulate will by default discard any record with missing values for any of the class variables unless the option /missing is provided on the class statement.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2020 18:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/some-observations-with-use-of-class-and-by-statement-in-proc/m-p/663861#M78947</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-21T18:15:21Z</dc:date>
    </item>
  </channel>
</rss>

