[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: value labels
What you have done wrong is confuse
two distinct ideas. Assigning value
labels to a numeric variable doesn't
mean that it becomes a string variable.
list var2 if sex == "male"
is legal if and only if -sex- is a string
variable. But it is still a numeric
There is a way to do what you want.
It is documented at [U] 13.9 (guessing,
can't find my copy at this moment) and in
SJ-4-4 dm0009 . . . . . . . Stata tip 14: Using value labels in expressions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K. Higbee
Q4/04 SJ 4(4):486--487 (no commands)
tips for using value labels in expressions
The way is
list var2 if sex == "male":lab_sex
In other words, you can do this so long as you _also_
specify the labelname. The usefulness of this is emphasised
in the places cited. On the other hand, you might
decide just to do it all the old way. Or, yet again,
you might prefer to -decode- (but note the storage
Raoul C Reulen
> 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?
* For searches and help try: