DQ.CASE Function

Applies casing rules (upper, lower, or proper) to a string. The function also applies context-specific casing logic using a case definition in the SAS Quality Knowledge Base (QKB).

Category: Data Quality
Returned data type: Integer
Note: The returned value is a Boolean value where 1= success and 0 = error.

Syntax

DQ.CASE(case_def, casing_type, input, result)

Required Arguments

casing_type

integer numeric constant that specifies the type of casing that is applied, [1 = uppercase, 2 = lowercase, 3 = proper case].

input

a string representing the input value or input field name.

result

a string representing the output field name.

Optional Argument

case_def

a string representing the name of a case definition in the QKB. Pass an empty string to use the default casing algorithm.

Details

The DQ.CASE function applies casing rules to an input string and outputs the result to a field.
The function is a member of the data quality class. A data quality object can be declared as a variable and must then be initialized using a call to the function DQ_INITIALIZE.
You can specify one of three casing types: uppercase, lowercase, or propercase. When uppercase or lowercase is specified, the function applies Unicode uppercase or lowercase mappings to the characters in the input string. When propercasing is specified, the function applies uppercase mappings to the first letter in each word and lowercase mappings to the remaining letters.
The caller can invoke the use of a case definition. A case definition is an object in the QKB that contains context-specific casing logic. For example, a case definition implemented for the purpose of propercasing name data can be used to convert the string "Mcdonald" to "McDonald". Refer to the QKB documentation for information about what case definitions are available in your QKB. If you do not want to use a case definition, you can omit the case definition name by entering a blank string for the case definition parameter. In this case, generic Unicode case mappings are applied to the input string as described earlier.
Note: If you want to use a case definition, you must call DQ.LOADQKB before calling DQ.CASE. The function DQ.LOADQKB loads the contents of a QKB into memory and links that QKB with the data quality object. This enables DQ.CASE to access the case definition that you specify.

Example

data quality dq
 string output
 dq = dq_initialize()
 dq.case("", 1, "ronald mcdonald", output)
 // outputs "RONALD MCDONALD"
 
dq.case("", 3, "ronald mcdonald", output)
 // outputs "Ronald Mcdonald"
 
dq.loadqkb("ENUSA")
 dq.case("Proper (Name)", 3, "ronald mcdonald", output)
 // outputs "Ronald McDonald"