Skip to main content
MedCalc
Mail a PDF copy of this page to:
(Your email address will not be added to a mailing list)
working
Show menu Show menu

CATEGORISE function

Description

CATEGORISE("variable", "condition1", value1, "condition2", value2,...," conditionN", valueN [,defaultvalue] ) recodes a variable into different categories. If "condition1" is true then the function returns value1, else if condition2 is true then the function returns value2, etc.

The first parameter is the variable name and must be placed between quotation marks. The following parameters are a serious of conditions and values. The conditions must be placed between quotation marks. If a condition is true, the value that immediately follows it is returned as the result of the function.

The last parameter of the function (defaultvalue), which is optional, specifies a default value which is returned when none of the conditions is true.

Examples

CATEGORISE("VALUE","=0","Zero","<0","Negative",">0","Positive") returns the string value “Zero" when the variable VALUE contains the value 0, the string value "Negative" is returned when the variable VALUE is less than 0,

CATEGORISE("AGE",">60","old",">25,"middle-aged","young") returns the string value "old" when the variable AGE contains a value higher than 60, "middle-aged" is returned when AGE is higher than 25. In all other cases the function returns "young".

Related functions

See also