* Data step;
data wanted(keep=mean_tcost);
set test end=last;
if _n_=1 then sumtcost=tcost;
else sumtcost+tcost;
if last then do;
mean_tcost=sumtcost/_n_;
output;
end;
run;
* Sql;
proc sql;
create table wanted as
select mean(tcost) as mean_tcost
from test;
quit;
data wanted(keep=mean_tcost);
set test end=last;
if _n_=1 then sumtcost=tcost;
else sumtcost+tcost;
if last then do;
mean_tcost=sumtcost/_n_;
output;
end;
run;
* Sql;
proc sql;
create table wanted as
select mean(tcost) as mean_tcost
from test;
quit;