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: Selecting variables based on variable labels


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Selecting variables based on variable labels
Date   Sat, 8 Sep 2012 02:25:45 +0100

Look at -ds- (official) or -findname- (SJ). The latter is more versatile.

Example:

findname, varlabeltext(TYPE OF RESIDENCE*)

Nick

On Sat, Sep 8, 2012 at 2:09 AM, Mitch Downey <pmdowney@ucsd.edu> wrote:
> Hello,
>
> I'm using the National Longitudinal Survey of Youth. There are several
> series of variables where the same question was asked over multiple years.
> E.g.,
>
> R0188000  TYPE OF RESIDENCE R IS LIVING 79
> R0402800  TYPE OF RESIDENCE R IS LIVING 80
> R0612100  TYPE OF RESIDENCE R IS LIVING 81
> R0828400  TYPE OF RESIDENCE R IS LIVING 82
> R1075700  TYPE OF RESIDENCE R IS LIVING 83
> R1451400  TYPE OF RESIDENCE R IS LIVING 84
> R1798600  TYPE OF RESIDENCE R IS LIVING 85
> R2160200  TYPE OF RESIDENCE R IS LIVING 86
> R2369100  TYPE OF RESIDENCE R IS LIVING 87
>
> where R0188000 is the variable name and TYPE OF RESIDENCE R IS LIVING 79
> is the variable label. Unfortunately, the variable names are random. This
> makes it impossible to select a group of variables using res* (for
> instance) or res79-res87. The only way I can find this group of variables
> is by typing
> -- lookfor "TYPE OF RESIDENCE R IS LIVING" --
>
> I would like to identify a list of variables using the lookfor command and
> either create a list or rename them in a sequential way. Is there a way to
> do this? Can you build a variable list from lookfor results? My ultimate
> goal is to make the dataset long format, so if anyone has and idea to
> shortcut straight to that, I'm all ears.
*
*   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