I have lists of variables in local macros that I would like to use in a command, e.g.:
local a int1 int2 num1 num2 bin1 bin2 ...
local b int3 int4 bin3 num3 ...
Here variable num* int* and bin* are numeric, integer and binary respectively.
I want to run a foreach loop over of the variables in local a' and b', but only those that are integer-valued, namely, int1, int2, int3, ...
For this, I use findname command created by Nick Cox to find variables that are integer-valued, saving a list of corresponding variable names in a local macro. But I do not want to run it for all variables in a dataset but only for subsets of variables (designated in locals a, b, and so on), and then use the list in a subsequent command.
So for a list of integer variables in local a' and b' being local a_int' and b_int', I want to use is as below:
foreach var of varlist `a_int' `b_int'{
whatever command
}
foois in a list you can create a new variablefoo_qualifiesasgen foo_qualifies = 1which is 1 in all observations. And so on for other variables. I can't see why that is any use over and above whatfindnameprovides. Why do you want this? - Nick Cox