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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

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

Date |
Fri, 14 Nov 2008 12:51:39 -0000 |

Johannes Geyer has already pointed you to -ds-, which I think is a positive answer to your problem. I can't resist saying that in the time since I added selection according to characteristics to -ds- I can't recollect anyone wanting it, but the first example is especially welcome. A basic problem with your -if- syntax is that -if- as a qualifier with commands like -summarize- always acts to selects observations from a dataset. It can never be used to select variables. Nick n.j.cox@durham.ac.uk Jeph Herrin 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. * * 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/

**References**:**st: -varlist- using char[]?***From:*Jeph Herrin <junk@spandrel.net>

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

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