SETLOCALE Function

Specifies the locale keys for the current SAS locale.
Category: Locale

Syntax

Setting SAS Locale
SETLOCALE(sas_locale)
Customize single locale elements
SETLOCALE(key, value)
Customize single locale elements
SETLOCALE(category_name, sas_locale)

Required Arguments

sas_locale
specifies a SAS locale name by using the SAS name or the posix name. You can also specify the locale alias.
key
specifies a SAS locale element key. See the list of element keys in the Details section.
value
specifies a value for the locale element.
category_name
specifies the category name:
  • LC_TIME
  • LC_MONETARY
  • LC_NUMERIC
  • LC_ALL

Details

You can modify the following locale elements. The value of key must be less than the value of max length. You can specify the following values for type:
0 String.
1 Unsigned integer. You must use double quotation marks.
Locale Element Key
Max Length
Type
Category
DATESTYLE
3
0
PAPERSIZE
8
0
FTITLE
512
0
FTEXT
512
0
SIMFONT
512
0
SORTSEQ
8
0
MESSAGES
8
0
FORMATNAME_DATE
512
0
FORMATNAME_DATETIME
512
0
FORMATNAME_TIME
512
0
FORMATNAME_NUMERIC
512
0
FORMATNAME_PERCENT
512
0
FONT_SERIF
32
0
FONT_SANSSERIF
32
0
FONT_CURSIVE
32
0
FONT_FANTASY
32
0
FONT_MONOSPACE
32
0
BRUSH
32
0
SIMPLEX
32
0
COMPLEX
32
0
SWISS
32
0
ITALIC
32
0
DATE_FORMAT
512
0
LC_TIME
DATE_SHORT_FORMAT
512
0
LC_TIME
DATETIME_AMPM_FORMAT
512
0
LC_TIME
DATETIME_FORMAT
512
0
LC_TIME
DATETIME_SHORT_FORMAT
512
0
LC_TIME
DATETIME_WEEK_FORMAT
512
0
LC_TIME
DATETIME_WEEK_SHORT_FORMAT
512
0
LC_TIME
TIME_AMPM_FORMAT
512
0
LC_TIME
TIME_FORMAT
512
0
LC_TIME
DATE_WEEK_FORMAT
512
0
LC_TIME
DATE_WEEK_SHORT_FORMAT
512
0
LC_TIME
DATE_YYMM_FORMAT
512
0
LC_TIME
DATE_YYMM_SHORT_FORMAT
512
0
LC_TIME
DATE_MMDD_FORMAT
512
0
LC_TIME
DATE_MMDD_SHORT_FORMAT
512
0
LC_TIME
DATE_YEAR_FORMAT
512
0
LC_TIME
DATE_YEAR_SHORT_FORMAT
512
0
LC_TIME
DATE_YYQQ_FORMAT
512
0
LC_TIME
DATE_YYQQ_SHORT_FORMAT
512
0
LC_TIME
DATE_YYWW_FORMAT
512
0
LC_TIME
DATE_YYWW_SHORT_FORMAT
512
0
LC_TIME
DATE_SEP
8
0
LC_TIME
ABMON01
512
0
LC_TIME
ABMON02
512
0
LC_TIME
ABMON03
512
0
LC_TIME
ABMON04
512
0
LC_TIME
ABMON05
512
0
LC_TIME
ABMON06
512
0
LC_TIME
ABMON07
512
0
LC_TIME
ABMON08
512
0
LC_TIME
ABMON09
512
0
LC_TIME
ABMON10
512
0
LC_TIME
ABMON11
512
0
LC_TIME
ABMON12
512
0
LC_TIME
MON01
512
0
LC_TIME
MON02
512
0
LC_TIME
MON03
512
0
LC_TIME
MON04
512
0
LC_TIME
MON05
512
0
LC_TIME
MON06
512
0
LC_TIME
MON07
512
0
LC_TIME
MON08
512
0
LC_TIME
MON09
512
0
LC_TIME
MON10
512
0
LC_TIME
MON11
512
0
LC_TIME
MON12
512
0
LC_TIME
ABDAY1
512
0
LC_TIME
ABDAY2
512
0
LC_TIME
ABDAY3
512
0
LC_TIME
ABDAY4
512
0
LC_TIME
ABDAY5
512
0
LC_TIME
ABDAY6
512
0
LC_TIME
ABDAY7
512
0
LC_TIME
DAY1
512
0
LC_TIME
DAY2
512
0
LC_TIME
DAY3
512
0
LC_TIME
DAY4
512
0
LC_TIME
DAY5
512
0
LC_TIME
DAY6
512
0
LC_TIME
DAY7
512
0
LC_TIME
AM
512
0
LC_TIME
PM
512
0
LC_TIME
ABQTR1
512
0
LC_TIME
ABQTR2
512
0
LC_TIME
ABQTR3
512
0
LC_TIME
ABQTR4
512
0
LC_TIME
QTR1
512
0
LC_TIME
QTR2
512
0
LC_TIME
QTR3
512
0
LC_TIME
QTR4
512
0
LC_TIME
INT_CURRENCY_SYMBOL
3
0
LC_MONETARY
CURRENCY_SYMBOL
32
0
LC_MONETARY
MON_DECIMAL_POINT
8
0
LC_MONETARY
MON_THOUSANDS_SEP
8
0
LC_MONETARY
MON_GROUPING
3
1
LC_MONETARY
MON_POSITIVE_SIGN
8
0
LC_MONETARY
MON_NEGATIVE_SIGN
8
0
LC_MONETARY
MON_INT_FRAC_DIGITS
3
1
LC_MONETARY
MON_FRAC_DIGITS
3
1
LC_MONETARY
MON_P_CS_PRECEDES
3
1
LC_MONETARY
MON_P_SEP_BY_SPACE
3
1
LC_MONETARY
MON_P_SIGN_POSN
3
1
LC_MONETARY
MON_N_SIGN_POSN
3
1
LC_MONETARY
DECIMAL_POINT
1
0
LC_NUMERIC
THOUSANDS_SEP
1
0
LC_NUMERIC
GROUPING
3
1
LC_NUMERIC
POSITIVE_SIGN
8
0
LC_NUMERIC
NEGATIVE_SIGN
8
0
LC_NUMERIC
P_CS_PRECEDES
3
1
LC_NUMERIC
P_SEP_BY_SPACE
3
1
LC_NUMERIC
N_CS_PRECEDES
3
1
LC_NUMERIC
P_SEP_BY_SPACE
3
1
LC_NUMERIC
N_CS_PRECEDES
3
1
LC_NUMERIC
N_SEP_BY_SPACE
3
1
LC_NUMERIC
P_SIGN_POSN
3
1
LC_NUMERIC
N_SIGN_POSN
3
1
LC_NUMERIC
HEIGHT
3
1
WIDTH
3
1

Examples

Example 1

In the following locale example, the SETLOCALE function specifies the locale Japanese (jp_JP). The SETLOCALE function returns the previous locale. In this example, the previous locale was English_United States.
Statements
Results
data_null;
x=setlocale('ja_JP);
put x=;
run;
x=English_UnitedStates

Example 2

In the following example, the SETLOCALE function returns the locale name where the element values are being changed:
Statements
Results
data _null_;
x = setlocale("LC_MONETARY", 'zh_CN');
put x=; run;
x=Japanese_Japan

Example 3

In the following example, the SETLOCALE function changes the value of the specified key, DATE_YEAR_FORMAT:
Statements
Results
data_null;
x=setlocale('DATE_YEAR_FORMAT', '¥%Y');
put x=;
run;
x=%Y¥