Hi,
I have over a thousand dummy variables for 30,000 data entries. I want to find a way to count the number of times each one of those variables appears as 1 using a foreach 'variable' loop command. Would be helpful if there was another command. Here is the command I used:
After generating a new variable "fortier" to count the number of times a variable appears as '1', I then tried to replace it with a loop in the following way, where Stern and Pierneef are 2 out of the 1000 dummy variables.
foreach `var' of varlist Stern Pierneef {
replace fortier = count(`var') if `var'==1
}
I have over a thousand dummy variables for 30,000 data entries. I want to find a way to count the number of times each one of those variables appears as 1 using a foreach 'variable' loop command. Would be helpful if there was another command. Here is the command I used:
After generating a new variable "fortier" to count the number of times a variable appears as '1', I then tried to replace it with a loop in the following way, where Stern and Pierneef are 2 out of the 1000 dummy variables.
foreach `var' of varlist Stern Pierneef {
replace fortier = count(`var') if `var'==1
}
Comment