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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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