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

From |
Jeph Herrin <junk@spandrel.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: -varlist- using char[]? |

Date |
Thu, 13 Nov 2008 16:38:00 -0500 |

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/

**Follow-Ups**:**st: RE: -varlist- using char[]?***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: -varlist- using char[]?***From:*Johannes Geyer <JGeyer@diw.de>

**Re: st: -varlist- using char[]?***From:*Johannes Geyer <JGeyer@diw.de>

- Prev by Date:
**st: Conditional multinomial logistic regression** - Next by Date:
**st: Dropping min of two consecutive observations** - Previous by thread:
**st: Conditional multinomial logistic regression** - Next by thread:
**Re: st: -varlist- using char[]?** - Index(es):

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