09-09-2014 02:41 PM
I created SAS code using proc SQL to calculate a weighted mean by year. My SAS code is below. My weight variable is called bwght and I weight the variable called CPUE for each year. This code produces the weighted mean by year and calls it bwghtedAverage. However, I can't figure out how I an get proc sql to also provide me with the 95% confidence intervals for this mean. Any help would be greatly appreciated.
title 'Weighted Averages';
select Year, sum(CPUE*bwght)/sum(bwght) as bwghtedAverage
from (select Year, CPUE,
when bwght gt 0 then bwght
end as bwght
group by Year /*major_area_code*/;
09-09-2014 03:18 PM
Here's a good example of how and looking at the vardef option as well.
You'll still need to deal with the 0 or negative weights somehow before the proc.