BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Biniie
Fluorite | Level 6

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

Please try the sum function as below

 

Psum= sum(of p1-p5);
Thanks,
Jag

View solution in original post

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

Please try the sum function as below

 

Psum= sum(of p1-p5);
Thanks,
Jag
ballardw
Super User

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.

sas-innovate-white.png

Register Today!

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.

Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 923 views
  • 1 like
  • 3 in conversation