<?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: Proc summary YTD mean problem in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/734773#M28635</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281554"&gt;@PierreYvesILY&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just as a side note: Perhaps you aren't really happy with the alphabetical sort order of the month names in your PROC SUMMARY output (making it hard to recognize that the values are cumulative YTD sums). You can fix this by adding two more options to the CLASS statement for the month variable:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;class monat / mlf &lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;order=data preloadfmt&lt;/FONT&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 16 Apr 2021 16:20:40 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-04-16T16:20:40Z</dc:date>
    <item>
      <title>Proc summary YTD mean problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/734706#M28631</link>
      <description>&lt;P&gt;dear SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to calculate then sums and means on a year to date Basis of a large amount of data. I use a Format suggested by Paige Miller and that works perfectly well:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;* Format für die Berechnung der Durchschnitte für n Monate ;
proc format;
value ytd (multilabel) 
1							='Jan'
1,2							='Feb' 
1,2,3						='Mar'
1,2,3,4						='Apr'
1,2,3,4,5					='Mai'
1,2,3,4,5,6					='Jun'
1,2,3,4,5,6,7				='Jul'
1,2,3,4,5,6,7,8				='Aug'
1,2,3,4,5,6,7,8,9			='Sep'
1,2,3,4,5,6,7,8,9,10		='Oct'
1,2,3,4,5,6,7,8,9,10,11		='Nov'
1,2,3,4,5,6,7,8,9,10,11,12	='Dec'
; 
run;&lt;/PRE&gt;&lt;P&gt;My data are in a dataset with lots of variables - I'll post only Pictures of a limited view.&lt;/P&gt;&lt;P&gt;To calculate the YTD sums I used the following Code:&lt;/P&gt;&lt;PRE&gt;* Berechnung der monatlichen Durchschnitte ;
proc summary data=Dashboard_Primaerdaten;
class mr_group marktregion_bt nlbez_bt mbrbez_bt filbez_bt jahr ;
class monat/mlf;
var ORB: NGS: DrK: ;
types () 
jahr 
jahr*monat 
jahr*monat*mr_group
jahr*monat*mr_group*marktregion_bt 
jahr*monat*mr_group*marktregion_bt*nlbez_bt 
jahr*monat*mr_group*marktregion_bt*nlbez_bt*mbrbez_bt 
jahr*monat*mr_group*marktregion_bt*nlbez_bt*mbrbez_bt*filbez_bt
;
output out=FIL3_bis (drop=_:) sum=;
format monat ytd.;
run;&lt;/PRE&gt;&lt;P&gt;and got the following CORRECT results:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS_Bild_0421_1.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58117i59AB81F5853D6F2D/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS_Bild_0421_1.PNG" alt="SAS_Bild_0421_1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To calculate the YTD means, I used the following Code:&lt;/P&gt;&lt;PRE&gt;* Berechnung der monatlichen Durchschnitte ;
proc summary data=Dashboard_Primaerdaten;
class mr_group marktregion_bt nlbez_bt mbrbez_bt filbez_bt jahr ;
class monat/mlf;
var ORB: NGS: DrK: ;
types () 
jahr 
jahr*monat 
jahr*monat*mr_group
jahr*monat*mr_group*marktregion_bt 
jahr*monat*mr_group*marktregion_bt*nlbez_bt 
jahr*monat*mr_group*marktregion_bt*nlbez_bt*mbrbez_bt 
jahr*monat*mr_group*marktregion_bt*nlbez_bt*mbrbez_bt*filbez_bt
;
output out=FIL3_bis (drop=_:) mean=;
format monat ytd.;
run;&lt;/PRE&gt;&lt;P&gt;and I got the following results, which are NOT correct:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS_Bild_0421_2.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58118i8D64BC425F225974/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS_Bild_0421_2.PNG" alt="SAS_Bild_0421_2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Obviously, the values of ORB_Anzahl_Akt are false ; the value for Jahr = 2000 and Monat = ' ' should be 332913 / 12 for instance, instead of 31.0119&lt;/P&gt;&lt;P&gt;What is the Problem in the Code?&lt;/P&gt;&lt;P&gt;How can I fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PY&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 11:49:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/734706#M28631</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2021-04-16T11:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc summary YTD mean problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/734707#M28632</link>
      <description>&lt;P&gt;When you ask for the mean, you get sum/N (that's how the mean is defined) which is&amp;nbsp;&lt;SPAN&gt;332913/N, and not 332913/12. You probably ought to do the calculation of 332913/12 in a DATA step.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 11:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/734707#M28632</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-16T11:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc summary YTD mean problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/734773#M28635</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281554"&gt;@PierreYvesILY&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just as a side note: Perhaps you aren't really happy with the alphabetical sort order of the month names in your PROC SUMMARY output (making it hard to recognize that the values are cumulative YTD sums). You can fix this by adding two more options to the CLASS statement for the month variable:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;class monat / mlf &lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;order=data preloadfmt&lt;/FONT&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Apr 2021 16:20:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/734773#M28635</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-04-16T16:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc summary YTD mean problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/734875#M28643</link>
      <description>&lt;P&gt;Instead of MONAT, consider using a YTD analog, via an intermediate data set view:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data vneed/ view=vneed;
  set Dashboard_Primaerdaten;
  do ytd_group=1 to monat; output; end;
run;

proc summary data=vneed;
  class mr_group marktregion_bt nlbez_bt mbrbez_bt filbez_bt jahr ytd_group ;
  ... 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Apr 2021 13:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/734875#M28643</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-04-17T13:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc summary YTD mean problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/735234#M28665</link>
      <description>very good tip, thanks a lot!</description>
      <pubDate>Mon, 19 Apr 2021 13:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/735234#M28665</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2021-04-19T13:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc summary YTD mean problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/735235#M28666</link>
      <description>I'll try this and send you feedback</description>
      <pubDate>Mon, 19 Apr 2021 13:03:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/735235#M28666</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2021-04-19T13:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc summary YTD mean problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/736592#M28741</link>
      <description>&lt;P&gt;hello Reinhardt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the proposed Code doesn't Change anything to my previous (false) results.&lt;/P&gt;&lt;P&gt;This is not the right way, unfortunately.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Apr 2021 14:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/736592#M28741</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2021-04-23T14:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc summary YTD mean problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/736594#M28742</link>
      <description>sorry, this post was for mkeintz</description>
      <pubDate>Fri, 23 Apr 2021 14:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-summary-YTD-mean-problem/m-p/736594#M28742</guid>
      <dc:creator>PierreYvesILY</dc:creator>
      <dc:date>2021-04-23T14:14:01Z</dc:date>
    </item>
  </channel>
</rss>

