Hello,

I'm endeavoring to loop over two locals. The first local is made up variables consisting of survey data indicating participation in a given program, the second local consists of variables indicating if the program was helpful. I would like a loop that first presents the tabulate command on participation, then applies the tabulate command to how helpful respondents found the program for those who participated.

Essentially, I'd like to get the following:

Code:
tab program1
tab helpful1 if program1==1
tab program2
tab helpful2 if program2==1
and so on.

I've tried the following:

Code:
forvalues a = 1/7 {
local programs program1 program2 program3 program4 program5 program6 program7
local helpful helpful1 helpful2 helpful3 helpful4 helpful5 helpful6 helpful7
foreach p of local programs{
    foreach h of local helpful{
        tab `p'
        tab `h' if `p'==1
    }
}
}
The code runs, but I get tabulation for each helpful variable for respondents who are participating in all programs (i.e: helpful1 for program1==1, program2==1, program3==1, etc. and so on). I suspect I'm not understanding how to effectively useful forvalues here but would appreciate any assistance folks can offer.

Thanks for any assistance you can provide!