<?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: Formatting help! I need to calculate avg and stddev of prices per quarter per year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatting-help-I-need-to-calculate-avg-and-stddev-of-prices-per/m-p/596711#M171856</link>
    <description>&lt;P&gt;If you need to format statistics by class levels, you'd be better off using PROC TABULATE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oops, Reading&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt; 's response made me realize I sent the wrong code. Here's the right code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data GAS;
  input year month gasprice;
  gasdate=mdy(month,1,year);
datalines;
2003 1 1.47
2003 4 2.06
2003 8 1.89
2004 3 2.00
2004 8 2.69
2004 9 3.00
run; 
proc tabulate data=work.gas  noseps;
  class gasdate;
  format gasdate yyq6. ;
  var gasprice;
  table gasdate   /*Row identifiers */
        ,
        gasprice*(n*f=3.0 mean*f=dollar8.0  std*f=dollar8.2)  /*Column specification*/
        ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Oct 2019 01:41:44 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2019-10-16T01:41:44Z</dc:date>
    <item>
      <title>Formatting help! I need to calculate avg and stddev of prices per quarter per year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-help-I-need-to-calculate-avg-and-stddev-of-prices-per/m-p/596695#M171849</link>
      <description>&lt;P&gt;Formatting help! I need to calculate avg and stddev of prices per quarter per year and present the price with a dollar format that will show the price having a dollar sign and two decimal spaces. Here is a sample of the data:&lt;/P&gt;&lt;P&gt;Year Month Gasprice&lt;/P&gt;&lt;P&gt;2003 1 1.47&lt;/P&gt;&lt;P&gt;2003 4 2.06&lt;/P&gt;&lt;P&gt;2003 8 1.89&lt;/P&gt;&lt;P&gt;2004 3 2.00&lt;/P&gt;&lt;P&gt;2004 8 2.69&lt;/P&gt;&lt;P&gt;2004 9 3.00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I have so far:&lt;/P&gt;&lt;P&gt;proc means data=work.gas&lt;BR /&gt;mean&lt;BR /&gt;stddev ;&lt;/P&gt;&lt;P&gt;class year month;&lt;/P&gt;&lt;P&gt;format month yyqd.&lt;BR /&gt;mean DOLLAR8.0;&lt;/P&gt;&lt;P&gt;var gasprice;&lt;BR /&gt;output out=work.gas2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think i just need to figure out the correct formatting!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 00:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-help-I-need-to-calculate-avg-and-stddev-of-prices-per/m-p/596695#M171849</guid>
      <dc:creator>K_Wils15</dc:creator>
      <dc:date>2019-10-16T00:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting help! I need to calculate avg and stddev of prices per quarter per year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-help-I-need-to-calculate-avg-and-stddev-of-prices-per/m-p/596706#M171854</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/295349"&gt;@K_Wils15&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;First, your format YYQD. assigned to Month won't work as intended. You need to create a variable where Year and Month are combined to represent a SAS date. Second, assign the DOLLAR format to the Gasprice, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                                                                                                             
  input year month gasprice ;                                                                                                           
  date = mdy (month, 1, year) ;                                                                                                         
  cards ;                                                                                                                               
2003 1 1.47                                                                                                                             
2003 4 2.06                                                                                                                             
2003 8 1.89                                                                                                                             
2004 3 2.00                                                                                                                             
2004 8 2.69                                                                                                                             
2004 9 3.00                                                                                                                             
;                                                                                                                                       
run ;                                                                                                                                   
                                                                                                                                        
proc means noprint data = have nway ;                                                                                                   
  class date ;                                                                                                                          
  var gasprice ;                                                                                                                        
  format date yyqd. gasprice dollar8.2 ;                                                                                                
  output out = stats (drop = _:) mean= stddev= / autoname ;                                                                             
run ;                                                          
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 01:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-help-I-need-to-calculate-avg-and-stddev-of-prices-per/m-p/596706#M171854</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-16T01:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting help! I need to calculate avg and stddev of prices per quarter per year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-help-I-need-to-calculate-avg-and-stddev-of-prices-per/m-p/596711#M171856</link>
      <description>&lt;P&gt;If you need to format statistics by class levels, you'd be better off using PROC TABULATE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oops, Reading&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt; 's response made me realize I sent the wrong code. Here's the right code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data GAS;
  input year month gasprice;
  gasdate=mdy(month,1,year);
datalines;
2003 1 1.47
2003 4 2.06
2003 8 1.89
2004 3 2.00
2004 8 2.69
2004 9 3.00
run; 
proc tabulate data=work.gas  noseps;
  class gasdate;
  format gasdate yyq6. ;
  var gasprice;
  table gasdate   /*Row identifiers */
        ,
        gasprice*(n*f=3.0 mean*f=dollar8.0  std*f=dollar8.2)  /*Column specification*/
        ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 01:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-help-I-need-to-calculate-avg-and-stddev-of-prices-per/m-p/596711#M171856</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-16T01:41:44Z</dc:date>
    </item>
  </channel>
</rss>

