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:
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.
Hi debdippal,
Average = mean(Score_assignment, Score_quiz, Score_forum);
Hi debdippal,
Average = mean(Score_assignment, Score_quiz, Score_forum);
vxhong17 is correct. Read the documentation on the mean() function and you will see that it automatically omits missing values from its calculations.
Richard
Thanks
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.