That is because you have a datetime (05Mar2019:15:00:00), not a date (05Mar2019) variable so you have the wrong format applied.
(Your first post shows a date format not a datetime).
Try using DTYEAR. instead.
proc summary nway data=Sample_table;
class Date;
format Date dtyear.;
var AB2_Water_MBD AB2_PWR_MW;
output out=means mean=;
title 'Yearly Average of the Water and Power';
run;
proc print data=means;
run;
Not 100% sure if there is a DTYEAR format.
@naeemomer wrote:
Morning,
There seems to be an issue, either with my data-set (and Date format) or with the code you shared.
My data looks like the following (here is just a snapshot - the dataset contains 4 years of data points)
Using the code provided, I get following, which is definitely not what I am looking for. I am looking for yearly averages, for the two variables (which one can calculate in python using "df.resample('Y').sum()" ).
I used the following code and got the result illustrated (in attached figure). I shall appreciate any clues/hints to improve the solution in SAS Code
proc summary nway data=Sample_table;
class Date;
format Date year.;
var AB2_Water_MBD AB2_PWR_MW;
output out=means mean=;
title 'Yearly Average of the Water and Power';
run;
proc print data=means;
run;
Thanks and regards,
Omar
... View more