I'm trying to compute annual averages and standard deviations of max and min temperatures,. My code is as follows:
PROC SQL;
create table new2 as
select date,SUM(max_temp) as max_temp,SUM(min_temp) as min_temp,
SUM(precip) as precip
from WORK.ROCH_DATA
group by date;
create table average2 as
select year(date) as year,(date) as year2,avg(max_temp) as maxavg,
avg(min_temp) as minavg, avg(precip) as avgprecip, std(max_temp) as
stdmaxtemp,
std(min_temp) as stdmintemp,std(precip) as stdprecip
from new2
group by year;
QUIT;
My code ends up spitting something on the likes of this;
It repeats the year2 and year column (I only want one with the proper year ie 1916.1917) and keeps recalculating a single year. How do i just get it to show me the single calculations of the 50 years in my data? (ie exclude the recalculations)
Since this is the 4th time you've asked this same question here's an answer, though I don't see what was wrong with several of the others. Two ways using proc means. You can use either the output or ODS OUTPUT, I've coded both but it's not required.Your end result is 3 data sets that should have what you want, in different formats likely.
proc means data=roch_data noprint stackods;
class date;
format date year4.;
var max_temp min_temp precip;
output out=summary_proc_mean1 mean= std= /autoname;
ods output summary=summary_proc_mean2;
run;
Using Proc SQL
PROC SQL;
create table average2 as
select year(date) as year,
avg(max_temp) as maxavg,
avg(min_temp) as minavg,
avg(precip) as avgprecip,
std(max_temp) as stdmaxtemp,
std(min_temp) as stdmintemp,
std(precip) as stdprecip
from roch_data
group by year;
QUIT;