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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 5 replies
  • 815 views
  • 1 like
  • 3 in conversation