I've a dataset with a very large number of variables
in a number of files. The variables are named according
to no apparent plan; however, I need to keep the names
for various reasons beyond my control.
So, using the data dictionary I was able to automate a process
of assigning meaningful char[] values to all of these variables.
Thus, for example, I can check if a variable came from a certain
file by checking the the char[].
This has been helpful in a lot of programming contexts.
For instance, I currently pull out the variables that form
the KCCQ survey scale by looping over ALL the variables
foreach V of _all {
local scale = V[scale]
if "`scale'"=="KCCQ" {
...
}
}
This is awkward to say the least; more importantly, it doesn't
help me interactively if, for instance, I want to type
. sum if char[scale]=="KCCQ"
But no variation on this syntax seems to work.
So I guess this question has two parts.
1. Is there a direct way to create a macro which contains
the names of all variables matching a certain characteristic?
And by direct I suppose I mean other than looping over all
variables.
2. Is there a way to reference such a subset interactively,
as above?
I think the answer is no to both, but thought it worth asking.
thanks,
Jeph
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/