Hi all,

Back with another simple question on variable creation that is nonetheless stumping me. I have a dataset goes through a list of exercises and records whether or not each respondent did that exercise yesterday (Yes = 1, No = 2).

There are three exercises in particular that I’m interested in (jog, jump_rope, and swim) I would like to generate a new variable that counts the number of these exercises that each respondent did. So if they answered “yes” (coded 1) for two of the three exercises, their value for the new variable is “2.”

I know how to create categorical from continuous, but not the other way around. Please help!

Data is below - thanks in advance.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str3 Name byte(warm_up jog bike jumprope walk hike swim yoga aerobics weights_arms weights_legs weights_torso stretch)
"AAA" 1 1 2 1 2 2 1 2 1 1 2 1 1
"BBB" 2 2 2 2 2 2 2 2 2 2 2 2 2
"CCC" 2 2 2 1 2 1 1 2 2 2 2 2 1
"DDD" 1 1 2 2 1 1 2 2 2 2 2 2 1
"EEE" 1 2 2 2 2 2 2 2 1 2 2 2 2
"FFF" 1 2 2 2 2 2 2 2 2 2 2 1 2
"GGG" 2 2 2 2 2 2 2 2 2 2 2 2 2
"HHH" 2 2 2 2 2 2 1 2 1 2 2 2 1
"III" 1 2 2 2 2 2 2 2 1 2 2 2 2
"JJJ" 2 2 1 2 2 2 2 2 1 2 2 2 2
"KKK" 1 2 2 2 2 2 2 2 2 2 1 2 2
"LLL" 2 2 2 2 2 2 1 2 1 2 2 2 2
"MMM" 1 2 2 2 2 2 2 2 2 2 2 2 1
"NNN" 2 1 1 1 2 2 1 2 2 2 1 2 1
"OOO" 1 2 2 2 2 2 2 2 1 2 2 2 2
"PPP" 2 2 2 2 2 2 2 2 2 2 1 2 2
"QQQ" 1 1 1 2 1 2 2 1 2 2 1 2 1
"RRR" 1 2 2 2 1 2 2 2 2 2 1 2 2
"SSS" 1 2 2 2 2 2 1 2 2 2 2 2 1
end