Hi folks,
Can anybody shed some insight on the procedure to use for calculating the variance of a weighted sum? Basically what I'm looking for is SAS 9.3 code to calculate var(z) in the following equation:
var(z) = a^2[var(x)] + b^2[var(y)]
a&b are the weights, x&y are the variables for which variance is to be calculated. More information can be provided if necessary.
Thanks in advance for considering.
proc means , proc summary ,proc univariate ........... can do it.
proc means data=sashelp.class nway noprint; class sex; var height; weight age; output out=want var=height_weight_var ; run;
Ksharp
To use two different weights you will need to make a pass through means for each weight variable.
Then combine the two resulting data sets to calculate your var( Z).
Ou. Sorry ! I misunderstood what op mean. I even don't notice there are two variables being the weight.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.