Statalist The Stata Listserver


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

st: RE: How do you look up a value label?


From   "David Harrison" <david.harrison@icnarc.org>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: How do you look up a value label?
Date   Mon, 12 Jun 2006 16:59:13 +0100

Use the macro extended function -label-, e.g.

. local lab1 : label valuecats 1

. di "`lab1'"
one

David 

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Richard
Atkins
Sent: 12 June 2006 16:53
To: statalist@hsphsun2.harvard.edu
Subject: st: How do you look up a value label?

Is there an easy way to look up a value label? 

To illustrate, imagine I have a variable 'value' containing integer
values 1 2 or 8 for numerous cases.
I define value labels

. lab def valuecats 1"one" 2"two" 8"a few" 
. lab val values valuecats

then tabulate it and save result in matricees

. tab values, matcell(F) matrow(V)

Now I want to extract the information to form my own table.

I can access the value V[3,1] which (in this case) will be 9.  However
this number is now isolated from the original variable and label
mapping. Is there any simple(ish) lookup function I can use to map from
a value to a value label? Presumably there must be as Stata is able to
do this but is it accessible to us mortals?

P.S. I am aware I could use the 'uselabel' command to obtain a dataset
with these mappings but I want to be able to do this without destroying
the original data.

Thanks.


Richard J. Atkins
Department of Epidemiology and Population Health London School of
Hygiene and Tropical Medicine Keppel Street, London WC1E 7HT
E-mail: richard.atkins@lshtm.ac.uk
Homepage: http://www.lshtm.ac.uk/ncdeu/staff/ratkins.html

Tel: 020 7927 2968  

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

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index