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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
TOTAL_PAHRS= sum(MET_MODRECHRS, MET_VIGRECHRS, MET_MODWORKHRS, MET_VIGWORKHRS);
--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26
TOTAL_PAHRS= sum(MET_MODRECHRS, MET_VIGRECHRS, MET_MODWORKHRS, MET_VIGWORKHRS);
--
Paige Miller
novinosrin
Tourmaline | Level 20

why not take advantage of var lists?

 

TOTAL_PAHRS= sum(of MET_:);

 

PaigeMiller
Diamond | Level 26

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_:

--
Paige Miller
novinosrin
Tourmaline | Level 20

Oh well, I didn't think of that. Well that's what makes your analytical reasoning smarts distinct and superior

epi101
Fluorite | Level 6

It works!! Thank you!!! 🙂

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1112 views
  • 1 like
  • 3 in conversation