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   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index