I am trying to write code to handle missing items from survey data. The survey is the AM-PAC outpatient basic mobility (contains 18 questions), and per the survey instructions, to score surveys with missing data, you are supposed to find the average score for the survey's non-missing items, and then input that average score for the missing items.
Here is a snapshot of my data:

So you can see in obs 5 (pid SP_002), there are 3 missing items (highlighted in yellow); I've added a variable for the row mean (ampac_mean), and this rows mean is the value highlighted in yellow in the last column.
How do I input that value (2.13) for the missing items in that row?
I have additional rows with missing data so I will need to be able to input that row's mean value into the missing items.
Thank you,
Michelle