Hello, I have a cross-sectional dataset with many variables, and I am attempting to compile a list (disaggregated by my groupvar, county) of instances in which any variable takes on the value of 5.
I have attempted to do this using the foreach command to loop through all variables, but I'm having some trouble.
When I use the code below, I get the "type mismatch r(109)" error message.
foreach var of varlist all {
by county: list if `var' == 5
}
Assuming this occurred because I was not restricting my loop to numeric variables, I attempted to isolate all of the numeric variables with
ds, has(type numeric)
However, when I apply the code above, it returns a list of all variables.
Does anyone have any tips on the best way to compile of list of cases in which a variable takes on a particular value?
Many thanks!
Dan
I have attempted to do this using the foreach command to loop through all variables, but I'm having some trouble.
When I use the code below, I get the "type mismatch r(109)" error message.
foreach var of varlist all {
by county: list if `var' == 5
}
Assuming this occurred because I was not restricting my loop to numeric variables, I attempted to isolate all of the numeric variables with
ds, has(type numeric)
However, when I apply the code above, it returns a list of all variables.
Does anyone have any tips on the best way to compile of list of cases in which a variable takes on a particular value?
Many thanks!
Dan
Comment