dear SAS experts, 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: * 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; My data are in a dataset with lots of variables - I'll post only Pictures of a limited view. To calculate the YTD sums I used the following Code: * 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; and got the following CORRECT results: To calculate the YTD means, I used the following Code: * 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; and I got the following results, which are NOT correct: 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 What is the Problem in the Code? How can I fix this? Regards, PY
... View more