Title

genif - Generate values by logical conditions

Syntax

genif [type] newvar = (value_if) [(value_if) ...] [(default_value)]

where value_if is

value if condition

and where value, condition, and default_value are valid stata expressions.

Description

genif creates a new variable, and determines its values by evaluating, in order, the conditions in the list. If the first condition evaluates to true, the variable takes on the first value. Otherwise, if the second condition
evaluates to true, the variable takes on the second value, etc.

If no condition is true, the value is set to default_value, if specified, or otherwise missing.

Example

. genif happy= (10,sun=="shining") (7,sky=="blue") (3,temp=="warm") (2)