[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: value labels
On Thursday 18 May 2006 22:36, Raoul C Reulen wrote:
> I am trying to define value labels for a variable called 'sex'.
> . label define lab_sex 1 male 2 female
> . label values sex lab_sex
> However, now I want to list a different variable according to the value
> label like this:
> .list var2 if sex=="male"
> but that gives me an error message, but:
> .list var2 if sex==1
> works. What have I done wrong?
-label values- doesn't change the contents of a variable. Males still have
value 1, but for some commands---tabulate, for example---you will see "male"
displayed instead of 1.
Don't know exactelly what you want to achieve in the end. But you might
either create a new string variable based on the "sex" using -decode-, or
you might try
. list var2 if sex=="male":lab_sex
(The last line is explained in Stata tip 14 by Ken Higbee in SJ 4 (4)
+49 (0)30 25491-361
* For searches and help try: