DQLOCALEGUESS Function

Returns the name of the locale that is most likely represented by a character value.

Valid in: DATA step, PROC SQL, and SCL

Syntax

DQLOCALEGUESS(char, 'locale-guess-definition')

Required Arguments

char

specifies a character constant, variable, or expression that contains the value that is analyzed to determine the locale, according to the specified locale guess definition.

locale-guess-definition

specifies a character constant, variable, or expression that specifies the locale guess definition.

Details

The DQLOCALEGUESS function evaluates an input character value using the specified locale guess definition in each of the locales that are loaded into memory. An applicability score is generated for each locale in the locale list. The locale with the highest applicability score is returned by the function. The return value is the five-character abbreviation of the locale name, such as ENGBR for English, as used in Great Britain.
The name of the locale that is returned depends on the locales that are loaded into memory. The locales that are loaded into memory are determined by the value of the DQLOCALE= system option..
If multiple locales receive the highest applicability score, then the locale that is returned is determined by the value of DQLOCALE= system option. The function returns the highest-scoring locale that appears last in the list of locales that is specified for the DQLOCALE= system option. See Example 2.
If all locales receive an applicability score of zero, then the return value is determined in part by a setting within the specified locale guess definition. Each locale guess definition can be enabled for the setting Select the last locale given if no score can be computed. When all applicability scores are zero, the last locale in the DQLOCALE= list where this option is enabled will be the locale guessed. See Example 3.

Examples

Example 1: DQLOCALEGUESS Function

The following example returns the name of a locale as the value of LOC.
loc=dqLocaleGuess('101 N. Main Street', 'Address');

Example 2: DQLOCALEGUESS Function with Multiple Highest Applicability Scores

The following example loads into memory the locales ENUSA, ENGBR, and ENHKG and calls the DQLOCALEGUESS function.
options dqlocale=(ENUSA ENGBR ENHKG);
data _null_;
result = dqLocaleGuess(input, 'Country');
run;
For a given input value, assume that the applicability scores were assigned as follows:
  • ENUSA = 750
  • ENGBR = 750
  • ENHKG = 250
The value that is returned to the result variable is ENGBR. The ENUSA and ENGBR locales share the highest applicability score. ENGBR is listed last in the value of the DQLOCALE= system option.

Example 3: DQLOCALEGUESS Function When All Applicability Scores Are Zero

The following example loads into memory the locales ENUSA, ENGBR, and ENHKG and calls the DQLOCALEGUESS function.
options dqlocale=(ENUSA ENGBR ENHKG);
data _null_;
result = dqLocaleGuess(input, 'Country');
run;
For a given input value, assume that the applicability scores were zero for all three locales. Also assume that the Country locale guess definitions in the ENUSA and ENGBR locales enable setting Select the last locale given if no score can be computed. The same setting is disabled in the ENHGK locale. In this case, the function returns the value ENGBR, because ENGBR is the last locale in the DQLOCALE= list that also enables the setting.