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: Using value labels to create varlist


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Using value labels to create varlist
Date   Wed, 13 Mar 2013 10:55:22 +0000

If you like -ds- for this purpose, -findname- (SJ) provides the same
functionality -- and more besides, which could be helpful for other
problems. It is a personal second take on -ds-. The help for
-findname- comments on the complicated history of -ds-.

The syntax here could be

findname, vallabel(LABA)

In addition to the examples in the help, here are two more

. findname, all(@ == @[1])

finds all variables that are actually constants.(If values are all
equal to each other, they are certainly equal to the first value, and
conversely.)

. findname, all(missing(@))

should then be guessable.

Nick

On Wed, Mar 13, 2013 at 9:31 AM, Maarten Buis <maartenlbuis@gmail.com> wrote:
> On Wed, Mar 13, 2013 at 12:18 AM,  <J.Cunliffe1@lse.ac.uk> wrote:
>> So I got a dataset with about 1,500 (categorical) variables, but about
>> 70 value labels mixed in pretty randomly though out the variables. All
>> the value labels are slightly different and the categories change from
>> one value label to the next (some binary, some likert 5 point scales,
>> some 4 etc and so forth). For each variables with the same value label I
>> need to send some to missing (for instance with variables with value
>> label LABBG - need 5 and 6 to go to missing, for LABA, need 3 to go to
>> missing...). The changes are consistent for each variable with the same
>> value label...
>>
>> Is there a way to pick variables by their value label, alter the
>> variable by sending a few values to missing, then picking the next value
>> label... appreciate that I'll have to code up _how_ I want each value
>> label to behave, but it's the picking of the variables that has got me
>> stumped, lookfor doesn't seem to pick them...
>
> ds, has(vallabel LABA)
> di "`r(varlist)'"
>
>
> ds, has(vallabel LABBG)
> di "`r(varlist)'"
>
> Hope this helps,
> Maarten
>
> Ps. It is a Likert scale not a likert scale as it is named after a
> person: Rensis Likert.
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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