gen [s|i|d|f|b] var1 [= expression|resultvar|value]
The GEN command will create a new variable based on the expression, or equal to a
constant from a result variable. It is a equivalent to a define and let commands, with the variable type implied by
the expression. If the result of expression is boolean, var1 will be 0 (FALSE) or 1 (TRUE). Result variables are created
by some commands, e.g. means and describe.
If the user specifies type, that type of variable is generated:
gen s var1 = expression (s=Text/String)
gen d var1 = expression (d=Date)
gen i var1 = expression (i=Integer)
gen f var1 = expression (f=Float)
gen b var1 = expression (b=Boolean)
If the user does not specify type, then a float variable will be created.
Variable names in the GEN statement must be 10 or fewer characters.Variable names may not begin with a number or
contain spaced, hyphens or other punctuation, although the underline character "_" is allowed.
Numeric variables are floating if no decimal is specified; otherwise they are real or "floating point" numbers.
Generated variables begin with values set to missing if no expresion is indicated, otherwise the variable will be
initialized to the value indicated in the expression.
Output:
Var Name T10 of type Float and length: 14 decimals 6
As an output, EpiData writes a line informing the user that the new variable has been generated and the type and length of it.
Examples and Hints
GEN b AGELIMIT= AGE>18 (Will generate a boolean variable AGELIMIT, the value will be 1 (true if AGE is greater than 18)
GEN COUNT (Will generate a floating variable named COUNT. Initial value =0)
GEN d REFDATE=dmy(15,05,1999) (Will cretae a date variable, with 15/05/1999 as initial value)
Notice:
dmy is date funtion that indicates that the numbers in brakets are a date
Related Commands:
Define
Options:
No Options for this command
|
|
Output variables:
No output variables for this command
|
|
Output definition:
References:
Top