rep(X;L)

Returns the value paired up with the first item in a specified list that matches the given value.

Syntax

rep(X;L)

Input

Argument Type Description
X any A column name
L any A space or comma-separated list of pairs of values

L has the form: val1,repval1,val2,repval2...

All of the values in L must be the same type as X (integer, decimal, or text).

The number of items in the list must be even (i.e., the list must contain pairs of values).

Return Value

Returns the value paired up with the first item in L that matches X. If there is no match, returns X.

If X is N/A, the result is N/A. However, if X is the empty string (''), and one of the replacement pairs specifies that an empty string is to be replaced with something else, the result is the replacement value.

Sample Usage

X L rep(X;L)
2 2 20 3 30 20
'2' '2' '20' '3' '30' '20'
2.1 2.1,21.0,1.1,11.0 21
'2.1' '2.1','21.0','1.1','11.0' '21.0'
'lg' 'sm','small','md','medium','lg','large' 'large'
NA 2,20,1.1,11.0 NA
NA 2.1,21.0,1.1,11.0 NA
'' '2.1','21.0','1.1','11.0' ''
'' '2.1','21.0','','11.0' '11.0'