help gendummies

Title

gendummies -- Generates a set of dummy variables with suffixes taken from category codes

Syntax

gendummies varname
[, options]

prefix(name) prefix for generated dummy variables (default is to use as a prefix
the name of the variable from which the dummies are generated)

includemissing if specified, include missing values as zeros

Description

gendummies generates a set of dummy variables from a categorical variable, using as suffixes the codes
actually found in the data, with the option of generating a set of zeros on all dummy variables when varname
has a missing value.

SPECIAL NOTE ON MULTIPLE BATTERIES: gendummies uses the codes found in the data as suffixes for the generated
variables, thus permitting users to ensure consistent codes across disparate batteries of responses (e.g. behaviours,
attitudes, etc.) relating to the same items (e.g. political parties). This is in contrast to tab1, which uses
sequential suffixes starting at the number 1 for the generated variables, no matter how those variables were coded.

Options

prefix(name) if provided, prefix for the generated dummy variables (default is to use the name of the
variable from which the dummies are being generated).

includemissing if specified, missing values for varname will be coded as all zeros.

Examples:

Generate dummies named "religX" for different values (X) found in the data for the variable relig;
cases with a missing value on relig will be set to missing on all generated dummies.

. gendummies relig

Generate dummies for different values of VAR282 naming these by appending the values found to the
stub "churchatt"; cases with a missing value on VAR282 will be set to zero on all generated dummies.

. gendummies VAR282, prefix(churchatt_) includemissing