看帮助Factor variables的解释
Title
[U] 11.4.3 Factor variables
Base levels
You can specify the base level of a factor variable by using the ib. operator. The syntax is
Base
operator(*) Description
---------------------------------------------------------------------------------------------------------
ib#. use # as base, #=value of variable
ib(##). use the #th ordered value as base (**)
ib(first). use smallest value as base (the default)
ib(last). use largest value as base
ib(freq). use most frequent value as base
ibn. no base level
---------------------------------------------------------------------------------------------------------
(*) The i may be omitted. For instance, you may type ib2.group or b2.group.
(**) For example, ib(#2). means to use the second value as the base.
If you want to use group==3 as the base in a regression, you can type,
. regress y i.sex ib3.group
You can also permanently set the base levels of categorical variables by using the fvset command.
Selecting levels
You can select a range of levels -- a range of virtual variables -- by using the i(numlist). operator.
Examples Description
-----------------------------------------------------------------------------------------------------------
i2.cat a single indicator for cat==2
2.cat same as i2.cat
i(2 3 4).cat three indicators, cat==2, cat==3, and cat==4;
same as i2.cat i3.cat i4.cat
i(2/4).cat same as i(2 3 4).cat
2.cat#1.sex a single indicator that is 1 when cat==2 and sex==1, and is 0 otherwise
i2.cat#i1.sex same as 2.cat#1.sex
-----------------------------------------------------------------------------------------------------------
|