Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Partho Sarkar <partho.ss+lists@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Re: Accumulating variable names to exclude from a varlist |
Date | Sun, 4 Mar 2012 18:01:47 +0530 |
Brilliant & elegant! Many thanks, Daniel. As for your question: I am dealing with data from various sources, and not all the sorting variables are present in all the files, some of them are named differently etc. Partho On Sun, Mar 4, 2012 at 5:48 PM, daniel klein <klein.daniel.81@googlemail.com> wrote: > Partho, > > I would not use a loop to this. Instead try something like > > loc varstolookfor <your variable list here> > unab allvars : * > loc varsindata : list allvars & varstolookfor > > The local macro "varsindata" will hold all variable names in > "varstolookfor" that appear in the dataset. However, I do not see why > you want to sort different datasets by different variables. This > question is for you to answer of course. > > Also see > > h unab > h macro lists > > Best > Daniel > * * 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/