LIKE macro

The LIKE macro is available in HCL® Campaign and HCL Interact.

Syntax

data1 [NOT] LIKE data2

Parameters

data1

The cell range to compare. This can be a text string or an expression evaluating to a text string. For the format definition of data, see the "Macro Function Parameters" section in the chapter in this guide for your HCL product.

data2

The text pattern to compare all values in the specified column against. This can be a text string or an expression evaluating to a text string. The number of columns in data2 must equal the number of columns in data1, unless data2 is a constant. For the format definition of data, see the "Macro Function Parameters" section in the chapter in this guide for your HCL product.

An underscore (_) in data2 represents a wildcard character that will match any single character in data1. A percent sign (%) will match zero or more characters in data1.

Description

LIKE compares the two specified data ranges, returning a one if the strings match or a zero if they do not. It returns a new column for each input column, each containing the corresponding column in data1 compared to the corresponding column of data2 (that is, the first column of data1 is compared to the first column of data2, the second column with the second column, and so on).

If data2 is a string constant, each string in data1 is compared to that string. If data2 is a column, the calculations are performed on a row-by-row basis. The first row string in data1 is compared to the first row string of data2, the second row with the second row, and so on. This row-by-row calculation produces a result for each row up to the last string in the shortest column.

When comparing strings, case does not matter (that is, "Yes", "YES", "yes", and "yeS" are all considered equal).

Note: The LIKE macro has a negative version, NOT LIKE. The format for this is identical to LIKE. NOT LIKE returns a one if the string in data1 does not match the template defined by data2.

Examples

TEMP = "gold" LIKE "gold"

Creates a new column named TEMP containing the value one (since the two strings match).

TEMP = "No" LIKE "NO"

Creates a new column named TEMP containing the value one (string compares are case insensitive).

TEMP = V1 LIKE "gold%"

Creates a new column named TEMP, where each value is one if the corresponding row value of the column V1 is equal to the string "gold" followed by any number of characters. Otherwise, each value is zero.

TEMP = V1 LIKE "g_ld"

Creates a new column named TEMP, where each value is one if the corresponding row value of the column V1 is equal to the string "g" followed by any character, followed by "ld". Otherwise, each value is zero.

TEMP = V1 LIKE V1

Creates a new column named TEMP containing all ones (since every number is equal to itself).

TEMP = V1 LIKE V2

Creates a new column named TEMP, where each value is the row value of column V1 compared to the corresponding row value of column V2.

TEMP = V1:V3 LIKE V4:V6

Creates three new columns named TEMP, VX, and VY. The column TEMP contains the strings in V1 compared to the corresponding row strings of column V4. The column VX compares columns V2 and V5. The column VY compares columns V3 and V6.

TEMP = V1[10:20] LIKE V2 or TEMP = V1[10:20] LIKE V2[1:11]

Creates a new column named TEMP, where the first 11 cells contain the results of comparing the strings in rows 10-20 of column V1 to rows 1-11 of column V2. The other cells in TEMP are empty.

Related functions

Function Description
EQ Returns TRUE if one data range is equal to another
GE Returns TRUE if one data range is greater than or equal to another
GT Returns TRUE if one data range is greater than another
LE Returns TRUE if one data range is less than or equal to another
LT Returns TRUE if one data range is less than another
NE Returns TRUE if one data range is not equal to another