I want to compute a new numeric variabel, "Psum", as the sum of 5 other numeric variable, P1, p2, p3, p4, p5. A simpel way to do it could be:
Psum= p1+p2+p3+p4+p5;
Some datalines includes missing values for the five variables, which will result in a missing value for the new variabel for these datalines.
Is there any way to get around this? I want to sum up the variabels, but I want SAS just to "ignore" if there is a missing value in one or more of the five variables and sum of the rest. I have thought about changning all the missing values in these 5 variable into the value of "0", but I would prefer to use a procedure that just ignores the missings values.
Please try the sum function as below
Psum= sum(of p1-p5);
And if you have actual variable names that are not as nice just list them in the sum function:
Psum = sum (thisvar, thatvar, somethingelse, othervar, varx);
If you are interested most of the basic statistics are available using similar syntax: N Mean Min Max Range STD Var (variance) Skewness and others.
Perfect, thanks!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.