Command Reference : Special Expression Reference
  
 
@expand
Automatic dummy variables.
The @expand expression may be added in estimation to indicate the use of one or more automatically created dummy variables.
Syntax
@expand(ser1[, ser2, ser3, ...][, drop_spec])
creates a set of dummy variables that span the unique values of the input series ser1, ser2, etc.
The optional drop_spec may be used to drop one or more of the dummy variables. drop_spec may contain the keyword @dropfirst (indicating that you wish to drop the first category), @droplast (to drop the last category), or a description of an explicit category, using the syntax:
@drop(val1[, val2, val3,...])
where each argument corresponds to a category in @expand. You may use the wild card “*” to indicate all values of a corresponding category.
Example
For example, consider the following two variables:
SEX is a numeric series which takes the values 1 and 0.
REGION is an alpha series which takes the values “North”, “South”, “East”, and “West”.
The command:
eq.ls income @expand(sex) age
regresses INCOME on two dummy variables, one for “SEX=0” and one for “SEX=1” as well as the simple regressor AGE.
The @EXPAND statement in,
eq.ls income @expand(sex, region) age
creates 8 dummy variables corresponding to:
sex=0, region="North"
sex=0, region="South"
sex=0, region="East"
sex=0, region="West"
sex=1, region="North"
sex=1, region="South"
sex=1, region="East"
sex=1, region="West"
The expression:
@expand(sex, region, @dropfirst)
creates the set of dummy variables defined above, but no dummy is created for “SEX=0, REGION="North"”. In the expression:
@expand(sex, region, @droplast)
no dummy is created for “SEX=1, REGION="WEST"”.
The expression:
@expand(sex, region, @drop(0,"West"), @drop(1,"North"))
creates a set of dummy variables from SEX and REGION pairs, but no dummy is created for “SEX=0, REGION="West"” and “SEX=1, REGION="North"”.
@expand(sex, region, @drop(1,*))
specifies that dummy variables for all values of REGION where “SEX=1” should be dropped.
 
eq.ls income @expand(sex)*age
regresses INCOME on regressor AGE with category specific slopes, one for “SEX=0” and one for “SEX=1”.
Cross-references
See “Automatic Categorical Dummy Variables” for further discussion.