Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Re: Accumulating variable names to exclude from a varlist


From   daniel klein <klein.daniel.81@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: Accumulating variable names to exclude from a varlist
Date   Sun, 4 Mar 2012 13:18:43 +0100

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

--
Dear colleagues,

[...] I want to do the following:

Check a list of variables to see which of them exist in the file being
processed, build up a list of the ones that do exist, and then sort
the data by the existing variables.
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index