Dear users,
I am trying to create a overall total physical activity variable.
This is my code:
*TOTAL LEVEL OF PHYSICAL ACTIVITY (MET_hrs/WEEK);
TOTAL_PAHRS= MET_MODRECHRS + MET_VIGRECHRS + MET_MODWORKHRS + MET_VIGWORKHRS;
The problem with this is that is only taking those individuals who have values in each one of these variables and creating one. Which is increasing missing values.
My question is how do I create a variable that includes individuals who do all of these type of physical activity or do only one, or a combination.
My main goal is to create a final variable that assigns each individuals with a total physical activity MET score.
Thank you for your help!
TOTAL_PAHRS= sum(MET_MODRECHRS, MET_VIGRECHRS, MET_MODWORKHRS, MET_VIGWORKHRS);
TOTAL_PAHRS= sum(MET_MODRECHRS, MET_VIGRECHRS, MET_MODWORKHRS, MET_VIGWORKHRS);
why not take advantage of var lists?
TOTAL_PAHRS= sum(of MET_:);
If I could be 100% sure that there are no other variables that begin with MET_ in this data set, that's a good answer. But since I am not 100% sure (in fact, I have no idea what is in this data set), then I would not advise using MET_:
Oh well, I didn't think of that. Well that's what makes your analytical reasoning smarts distinct and superior
It works!! Thank you!!! 🙂
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.