Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: listing variables with certain characteristics


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   st: listing variables with certain characteristics
Date   Thu, 27 Aug 2009 15:02:19 -0400


I have often found it helpful to keep track of
metadata associated with variables by assigning
it as characteristics. So, for instance, a variable
which is of type checkbox, in module 6, question 3
of a survey might have

   myvar[type]:        checkbox
   myvar[module]:      6
   myvar[question]:    3

and so on. What I'm looking for is a good way to
generate a list of variables that have, eg, module=6.

Right now, the best I can do is

  ds, has(char module)

to get the list of variables that have a "module"
characteristic, then loop over that list to pick
out the ones where module=6. This bothers me because
(a) it seems there should be a better way than looping
and (b) -ds- seems to be on the verge of extinction.

I'm about to write  my own utility to do this, since
I need to do it so often, but thought I'd see if there
wasn't a better way already out there. Is there a
a direct way to get a list of variables where the
characteristic exists and has a certain value?

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index