How To Check SAS LOCALE Language Code (Handle Multilingual SAS Data)

There might be scenarios where you’re dealing with data from multiple languages. If you are working with a multinational client but their entire system uses the English language then you don’t need to worry about SAS Env LOCAL language. 

But if you have data sources coming from different countries and data prepared in their own local language then you may have difficulties dealing with those raw data.

What is a SAS LOCALE? 

A SAS LOCALE is a set of parameters that defines the user’s language, country, and any special variant preferences.

Check SAS Env Local Language Code

Before you do anything first get to know your SAS system and local language code set for the environment.

SAS system detailed information which is specifically related to language can be extracted using the following code.

/* check sas locale language code */

proc options group=languagecontrol;
run;
How To check SAS locale language code

SAS system information will be printed in the log window. You can search for LOCALE in the log and you’ll get the language code which is set for your SAS Environment. 

The LOCALE option Specifies a set of attributes in a SAS session that reflect the language, local conventions, and culture for a geographical region.

You can also use getpxLanguage() function to know your current session locale language code. 

Here is the simple code that you can use to print your current SAS session’s language code.

/* print current sas session locale value */
data GetLangCode;
	lang=getpxLanguage();
	put lang;
proc print;
run;
SAS session's locale language code

There are so many locale language code available. Here is the entire list of locale language codes which you may want to look at it. 

How To Change SAS LOCALE Language Code

The ENCODING system option is set explicitly in all SAS Foundation sasv9.cfg configuration files. You can change the locale language centrally by modifying the SAS configuration setting but it will be applicable throughout the system.

IMPORTANT NOTE:  DO NOT change the SAS configuration unless and until you have a good reason for doing that.

I would recommend another option to change the locale language only for your SAS code session by defying at the beginning of your program.

You can use the OPTIONS statement in your SAS code to change locale. Note: You will get a warning when changing the current locale to a locale which is not supported by current SAS session encoding. 

For example, under SAS session encoding wlatin1, change locale from en_US to zh_CN will be warned, and de_DE successfully.

I already know that my locale language code is EN, which is US English. Now let’s assume I want to deal with the data which is in FRENCH. 

First, I need to change my current SAS session’s locale language to FRENCH. This is how I would change LOCALE from EN to Fr.

/* set the locale language code for the current sas session */
options locale=french_france;

/* print current sas session locale value */
data GetLangCode;
	lang=getpxLanguage();
	put lang;
proc print;
run;
change sas locale lang code

FAQ

Why is SAS LOCALE important?

The SAS LOCALE is important as it determines the language settings for data processing and presentation in SAS, especially when handling multilingual data.

How can I check the current SAS LOCALE? 

You can check the current SAS LOCALE by using the LOCALE option in the PROC OPTIONS statement.

Can I change the SAS LOCALE? 

Yes, you can change the SAS LOCALE to handle data in different languages. However, it’s important to note that changing the LOCALE can affect the interpretation of data.

Does changing the SAS LOCALE affect my data? 

Changing the SAS LOCALE can affect your data, especially if the data contains characters that are not supported by the new LOCALE.