<?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: How to calculate average within  format ranges in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781225#M248992</link>
    <description>&lt;P&gt;I must be living in the past. Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Nov 2021 11:07:32 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-11-19T11:07:32Z</dc:date>
    <item>
      <title>How to calculate average within  format ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781140#M248959</link>
      <description>&lt;P&gt;Hello everyone&lt;/P&gt;&lt;P&gt;My worry is about having a deep understanding of&amp;nbsp; FORMAT&lt;/P&gt;&lt;P&gt;So i m trying to calculate the average within&amp;nbsp; each range that is created within the format&lt;/P&gt;&lt;P&gt;Following is the code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format;&lt;BR /&gt;value SalesRange 0 - &amp;lt;100000 = 'Lower'&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100000 - &amp;lt;200000 = 'Middle'&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 200000 - high = 'Upper';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data shoerange;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set sashelp.shoes;&lt;BR /&gt;salesreport = put(sales,SalesRange.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;title" sales report";&lt;BR /&gt;proc print data = shoerange;&lt;BR /&gt;var sales salesreport;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do i proceed to calculate the average of first range second range and third range&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 21:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781140#M248959</guid>
      <dc:creator>Armand_B</dc:creator>
      <dc:date>2021-11-18T21:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate average within  format ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781152#M248961</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value SalesRange 0 - &amp;lt;100000 = 'Lower'
            100000 - &amp;lt;200000 = 'Middle'
            200000 - high    = 'Upper';
run;

data shoerange;
      set sashelp.shoes;
salesreport = put(sales,SalesRange.);
run;

PROC MEANS data=shoerange;
 CLASS salesreport;
 var sales;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Nov 2021 21:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781152#M248961</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-18T21:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate average within  format ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781153#M248962</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value Salesf 0 - &amp;lt;100000 = 'Lower'
                     100000 - &amp;lt;200000 = 'Middle'
                    200000 - high = 'Upper';
run;

proc summary data=sashelp.shoes nway;
     class sales;
     format sales salesf.;
     var sales;
     output out=want mean=sales_mean/noinherit;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I changed the format name since it has to be 8 characters or less. No need to create a new variable with a PUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally, you would not want to slice the data by a variable (in this case SALES) and then do an analysis (compute the mean) of the same variable (SALES). What is the point? The mean in the Middle group has to be higher than the mean in the lower group, and has to be lower than the mean of the upper group. Normally, the slicing variable is different than the analysis variable.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 22:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781153#M248962</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-18T22:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate average within  format ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781210#M248987</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;I changed the format name since it has to be 8 characters or less.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;From the docs of proc format:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The name must be a valid SAS name. A numeric format name can be up to 32 characters in length. A character format name can be up to 31 characters in length. If you are creating a character format, then use a dollar sign ($) as the first character.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 10:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781210#M248987</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-11-19T10:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate average within  format ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781225#M248992</link>
      <description>&lt;P&gt;I must be living in the past. Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 11:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781225#M248992</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-19T11:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate average within  format ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781233#M248996</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; wrote: "I changed the format name since it has to be 8 characters or less. No need to create a new variable with a PUT statement."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;However, this works fine on my computer (running SAS 9.4):&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;                                
  value thisislongerthaneight 1='Hello'     
   other='nope';                            
run;                                        
data test;                                  
  do i=1 to 5;                              
    output;                                 
    j=44;                                   
    format i thisislongerthaneight.;        
    end;                                    
run;                                        
                                            
proc summary data=test;                     
  class i;                                  
  var j;                                    
  output out=mean mean=;                    
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;I think that limitation is a bit outdated.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 12:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781233#M248996</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2021-11-19T12:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate average within  format ranges</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781234#M248997</link>
      <description>Hi Andreas,&lt;BR /&gt;just to give the exact position:&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1upn25lbfo6mkn1wncu4dyh9q91.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1upn25lbfo6mkn1wncu4dyh9q91.htm&lt;/A&gt;</description>
      <pubDate>Fri, 19 Nov 2021 12:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-calculate-average-within-format-ranges/m-p/781234#M248997</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2021-11-19T12:46:54Z</dc:date>
    </item>
  </channel>
</rss>

