Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[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 <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index