SASMSGL Function

Specifies a message from a data set. The message is based on a specified locale value and a specified key value.
Category: Locale

Syntax

SASMSGL(("BASENAME", "KEY", "LOCALE", <<"Q"|"D"|"N">
<, "substitution 1", ..., "substitution 6">>)

Required Arguments

BASENAME
the name of the data set where the message is located.
KEY
the message key.
Note: If you specify an invalid key name, then the key name is returned.
LOCALE
the posix locale value (ll_RR).
QUOTE|DQUOTE|NOQUOTE
specifies the type of quotes that are added to the message text and substitution strings.
Default:DQUOTE
substitution
string substitutions. The maximum string substitutions is 6.

Details

The SAS message data set must be a 7-bit ASCII data set. Any character that cannot be represented in the 7-bit ASCII encoding is represented in the Unicode escape format of '\uxxxx, where the xxxx is the base 10 numeric representation of the Unicode value of the character.
The data set used by SASMSGL function must have been created specifically for use with this function. The dataset must contain the following variables:
#
Variable Name
Type
Length
Description
1
locale
char
5
language of the message
2
key
char
60
key to identify the message
3
lineno
num
5
line number of the message in reverse order
4
text
text
1200
text of the message
The data set must be sorted on the following variables: locale, key, and lineno. The variable lineno must be in descending order. A composite index on locale and key must be defined. Here is a sample program to sort and create an indexed data set:
%let basename=MyProduct;

proc sort data=t.&basename;
by locale key descending lineno;
run;

proc datasets lib=t 
memtype=data;
modify &basename;
index create indx=(LOCALE KEY);
run;
quit;
The returned message is based on the LOCALE system option. The LOCALE option is represented by ll_RR where ll represents the two- letter language code and RR represents the two-letter region code. If a match is not found, then the function searches for a match with the language only. If the pair locale and key are still not found, then the function defaults to the English language (en). If the key does not exist for English (en), then the key name is returned.
You can alter formatting. You can use string substitution by using the format code %s. You can change the order of substitution. In some cases, translation of a message to a language other than English might require changing the order of substitutions. You can change the order by placing an argument number specification, #nn, within a format string, where nn is the number of the argument in the substitution list. The following example demonstrates changing the order:
Statement
Result
msg = sasmsgl
("nls.mymsg","IN_CD_LOG","en_US","N",
"cat","dog");
IN_CD_LOGINFO = My %#1s. Your %#2s
msg= My cat. Your dog.
IN_CD_LOGINFO = My %#2s. Your %#1s
msg= My dog. Your cat.
The SASMSGL function can be used in the open code macro with the %SYSFUNC macro function.
Arguments that are passed to a function called by the %SYSFUNC macro must not be in quotes while arguments passed to the SASMSGL function outside of %SYSFUNC must be quoted.
When the SASMSGL function is used with the %SYSFUNC macro function, the returned string is wrapped with the %NRBQUOTE function.

Examples

Example 1

The following example demonstrates the formatting feature of SASMSGL:
Statements
Results
sasmsgl("nls.mymsg", "IN_APW_SAVE_OK", "en_US", "n"));
The Access Control key was successfully saved.
sasmsgl("nls.mymsg", "IN_APW_SAVE_OK", "es_ES", "n"));
La clave de control de acceso se ha guardado.
sasmsgl("nls.mymsg", "IN_APW_SAVE_OK", "fr", "n"));
La clé de contrôle d'accès a bien été enregistrée.
 

Example 2

The following example demonstrates the open macro feature:
SAS Statements
Results
%PUT %SYSFUNC(SASMSGL(NLS.MYDS, IN_ASD_LABEL, en_US));
"Edit"
%PUT %SYSFUNC(SASMSGL(NLS.MYDS, IN_ASD_LABEL, es_ES));
"Editar"
%PUT %SYSFUNC(SASMSGL(NLS.MYDS, IN_ASD_LABEL, fr));
"Modifier"