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

Suppose we have the values for each of the 3 variables eg. Score_assignment, Score_quiz, Score_forum for a set of students. Now I want to get the average value for each of the student.  But for some students values of one or more variables are missing. Then we will calculate the average by using the following formula:

  1. Ex.

Student No.

Score_assignment

Score_quiz

Score_forum

Average

1

10

15

45

(10+15+45)/3

2

14

20

(14+20)/2

3

41

41/1

Please write down a sas code such that I can calculate the average value using the above logic.

1 ACCEPTED SOLUTION

Accepted Solutions
vxhong17
Calcite | Level 5

Hi debdippal,

Average = mean(Score_assignment, Score_quiz, Score_forum);

View solution in original post

3 REPLIES 3
vxhong17
Calcite | Level 5

Hi debdippal,

Average = mean(Score_assignment, Score_quiz, Score_forum);

RichardinOz
Quartz | Level 8

vxhong17 is correct.  Read the documentation on the mean() function and you will see that it automatically omits missing values from its calculations.

Richard

debdippal
Calcite | Level 5

Thanks

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 631 views
  • 0 likes
  • 3 in conversation