Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Re: Multiple value labels


From   Ronnie Babigumira <[email protected]>
To   [email protected]
Subject   Re: st: RE: Re: Multiple value labels
Date   Mon, 27 Mar 2006 08:52:24 +0200

I may be off here but -label list- and not -table- may be what you are looking for.

. labmask var1, values(var2) //This creates a label called var1

To list the contents of this new label

. label list var1
var1:
         200 Building
         304 House
         666 Land

HTH




MA V wrote:
Thanks! And once I've assigned the labels, is ti possible to create tables (using the commands table or tabulate) that display both the numeric codes and the value labels?
Thanks,
MA_V



From: "Rosy Reynolds" <[email protected]>
Reply-To: [email protected]
To: "statalist" <[email protected]>
Subject: Re: st: RE: Re: Multiple value labels
Date: Sun, 26 Mar 2006 23:57:54 +0100

The Stata8 equivalent of -levelsof- was just called -levels-.
And labmask will work fine in Stata8 (or 7 for that matter).
Rosy

----- Original Message ----- From: "MA V" <[email protected]>
To: <[email protected]>
Sent: Sunday, March 26, 2006 11:41 PM
Subject: RE: st: RE: Re: Multiple value labels


Thanks so much for your suggestion.
One question: I have version 8.2 of Stata so I don't have the "levelsof"
command. Is there anyway of geeting this plug-in for my version? Or is
there a similar version of this command for Stata 8.2? I believe this
command would be very useful to me even in other contexts (that not the
value labels).
Thanks,
MA_V


From: "Nick Cox" <[email protected]>
Reply-To: [email protected]
To: <[email protected]>
Subject: st: RE: Re: Multiple value labels
Date: Sun, 26 Mar 2006 17:55:15 +0100

Thanks for the plug. I'd have to recommend -labmask-
myself as probably the most user-friendly solution here.

If it didn't exist, the problem yields to a few lines.

* check the assumption of correspondence in
your desired direction:

bysort var1 (var2) : assert var2[1] == var2[_N]

(compare:
How do I list observations in a group that differ on a variable?
http://www.stata.com/support/faqs/data/diff.html)

* get the distinct values of -var2-:

levelsof var2, local(levels)

foreach l of local levels {
su var1 if var2 == "`l'", meanonly
label def var1 `r(min)' "`l'", add
}

By assumption the values of -var1- given -var2-
are identical. So we can do a look-up by a -summarize-
of those values, and add a new value label each
time around the loop.

Then we link the labels to the variable:

label val var1 var1

Nick
[email protected]

Rosy Reynolds

> Nick Cox's nifty program -labmask-, part of the -labutil-
> suite, will do the
> job. It assigns the values (or optionally value labels) of
> one variable as
> the value labels of another.
> -findit labutil-

MA V

> > I have the following in my data:
> > obs        var1           var2
> > 1         304                House
> > 2         666                Land
> > 3         200                Building
> > 4         304                House
> > 5         304                House
> > ...       ...                  ....
> >
> > where var2 contains the labels for var1. Since I have many
> labels it will
> > not be easy to create the labels for var1 by hand. Is there an easy
> > procedure to make stata recognize that there is an unique
> correspondence
> > between var1 and var2 and to label var1 using var2?

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index