Hello,
I am working with a survey and i have several yes/no question. My goal is to count for each person how many questions he answered with yes (1).
Due to the high amount of questions I was thinking about using a loop, in this case a "foreach" loop sounds most fitting. But I am not quite sure.
Is this the best way of doing it, is there any other way?
Secondly I have tried something but I keep getting "invalid syntax" errors...
(pp24-pp72 is the list of variables I am working with)
foreach x for varlist pp24-pp72 {
count if `x' == 1
}
I think there is something major, that I am missing.
Does anybody can give me some adive on how to move forward
Btw i am using Stata 17.0
I am working with a survey and i have several yes/no question. My goal is to count for each person how many questions he answered with yes (1).
Due to the high amount of questions I was thinking about using a loop, in this case a "foreach" loop sounds most fitting. But I am not quite sure.
Is this the best way of doing it, is there any other way?
Secondly I have tried something but I keep getting "invalid syntax" errors...
(pp24-pp72 is the list of variables I am working with)
foreach x for varlist pp24-pp72 {
count if `x' == 1
}
I think there is something major, that I am missing.
Does anybody can give me some adive on how to move forward
Btw i am using Stata 17.0
Comment