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
}
If I understand you correctly, you need the intersection of two lists stored in local macros. To do this you can use the macro extended functions to manipulate lists: see
help macrolists
.