LOCASV: Creating a Variable Length Lowercase String

How to:

Available Languages: reporting

The LOCASV function converts alphabetic characters in the source string to lowercase and is similar to LOCASE. LOCASV returns AnV output whose actual length is the lesser of the actual length of the AnV source string and the value of the input parameter upper_limit.

Syntax: How to Create a Variable Length Lowercase String

LOCASV(upper_limit, source_string, output)

where:

upper_limit

Integer

Is the limit for the length of the source string.

source_string

Alphanumeric of type An or AnV

Is the string to be converted to lowercase in single quotation marks, or a field or variable that contains the string. If it is a field, it can have An or AnV format. If it is a field of type AnV, its length is taken from the length in bytes stored in the field. If upper_limit is smaller than the actual length, the source string is truncated to this upper limit.

output

Alphanumeric of type An or AnV

Is the name of the field in which to store the result, or the format of the output value enclosed in single quotation marks ('). This value can be for a field that is AnV or An format.

If the output format is AnV, the actual length returned is equal to the smaller of the source string length and the upper limit.

Example: Creating a Variable Length Lowercase String

In this example, LOCASV converts the LAST_NAME field to lowercase and specifies a length limit of five characters. The results are stored in the LOWCV_NAME field:

TABLE FILE EMPLOYEE
PRINT LAST_NAME AND COMPUTE
LOWCV_NAME/A15V = LOCASV(5, LAST_NAME, LOWCV_NAME);
WHERE DEPARTMENT EQ 'MIS';
END

The output is:

LAST_NAME        LOWCV_NAME
---------        ----------
SMITH            smith
JONES            jones
MCCOY            mccoy
BLACKWOOD        black
GREENSPAN        green
CROSS            cross