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
}
Related Posts with Foreach loop across variables
Hausman-test interpretation for RE vs FEHello, I have a queston on how to interpret a Hausman-test. Dependent variable (y) is suffering fro…
Mixed models repeated measuresHi, I'm trying to find the best model for answering a repeated measures problem. The research quest…
oprobit marginal effects - urgent pleaseI used the following estimation command to understand the interaction effect of ownership and knowle…
changing working directoryHi everyone, I recently updated to Stata 15. In the main window, I used to be able to change the wo…
Group identifier for individual panels: repeated time values within panelHi all, I'm hoping to be able to get some guidance on a work-around for the repeated time values wi…
Subscribe to:
Post Comments (Atom)
0 Response to Foreach loop across variables
Post a Comment