Presentation is loading. Please wait.

Presentation is loading. Please wait.

Make your SAS programs ready for any language

Similar presentations


Presentation on theme: "Make your SAS programs ready for any language"— Presentation transcript:

1 Make your SAS programs ready for any language
Lihsin Hwang Statistics Canada

2 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Agenda Concept and options Locale String Externalization Steps Demo First & last name Company name

3 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Concept and Options Concept Allow your application to speak multiple languages without changing the code Minimize the workload required to apply a new language Options Keep multiple SAS programs Multiple %put statements Format String Externalization First & last name Company name

4 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Locale Conventions for handling written language and various units Display of numbers, dates, currency..etc Identifies a specific user preference and represents a language in a geographical region First & last name Company name

5 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Set Locale sasv9.cfg -LOCALE “EN_GB” SAS system options Options locale=French_Canada; Options locale=en_US; setlocale(sas_locale) So how do we set and retrieve locale? Set: SAS support long name (SAS name) and short names (POSIX name) First & last name Company name

6 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Retrieve Locale getOption %LET PLOC=%SYSFUNC(getOption(LOCALE)); %PUT &PLOC ; ENGLISH_UNITEDSTATES getpxLocale: five-letter POSIX locale value (en_us) getpxLanguage: two-letter language (en) getpxRegion: two-letter region code (US) First & last name Company name

7 String Externalization Process
OASUS Spring or Fall YYYY Friday, November 16, 2018 String Externalization Process Identify and move translatable strings Create .smd file Convert .smd files Create the final SAS data set Retrieve the messages in your application First & last name Company name

8 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Process Step I Step 1: Identify and move translatable strings Excel file contains each language on a separate column First & last name Company name

9 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Process Step II Step 2: Create.smd file proc import, excel engine via PCFile Server… etc put together keys and values each localized .smd file, shared the same base name message.smd message_es_mx.smd message_fr.smd First & last name Company name

10 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Process Step III Step 3:Convert SMD files All characters that cannot be expressed as ASCII must be represented with UNICODE escape sequence Tools to use: KPROPDATA function (SAS) UNICODEC function (SAS) First & last name Company name

11 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Process Step IV Step 4: Create the final SAS data set Such data sets can be created with the %SMD2DS() macro function. The macro %SMD2DS is available in the SAS AUTOCALL library: %SMD2DS(DIR=,BASENAME=,LOCALE=,LIB=) %smd2ds ( dir = &base_dir, basename = message, locale = &locale_list lib = ); Contain four variables : path shared base name english french # Variables Name Type Length DESC 1 Locale char 5 Language of the message 2 Key 60 Key to identify the message 3 Lineno num line # of the message in reverse order 4 Text 1200 Text of the message First & last name Company name

12 Output Final output – SAS Data set 16/11/2018

13 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Process Step V Retrieve the messages in your application %SYSFUNC(SASMSG(BASENAME, KEY, <<QUOTE|Q|DQUOTE|D|NOQUOTE|N> <, substitute1, substitute2, ...>>) SASMSG("BASENAME", "KEY", <<"QUOTE"|"Q"|"DQUOTE"|"D"|"NOQUOTE"|"N"> <, "subs1", "subs2", ...>>) %PUT %SYSFUNC(SASMSG(&msgDataset, 00-1, D, &user, &adate)) ; %PUT %SYSFUNC(SASMSG(&msgDataset, 00-2, N)); %PUT %SYSFUNC(SASMSG(&msgDataset, 00-3, N, UnitID)); data _null_; msg = sasmsg("&msgDataset",“00-1","noquote" , "&user", "&adate"); put msg; run; First & last name Company name

14 Now your child is trilingual!
OASUS Spring or Fall YYYY Friday, November 16, 2018 Now your child is trilingual! Locale set to EN_CA "Hello Steve! Today's date is May 26." ERROR: Weight variable cannot have any other role assigned to it in the same table ERROR: UnitID variable must have at least one group Locale set to FR_CA "Bonjour Steve! Aujourd'hui nous sommes le 26 mai 2015." ERROR: Variable pondérée ne peut pas avoir d'autre rôle lui est attribué par la même table ERROR: UnitID variable doit avoir au moins un groupe Locale set to ES_MX "Hello Steve! Today's date is 26 de mayo de 2015." ERROR: Variable de peso no puede tener ninguna otra función asignada en la misma tabla ERROR: Variable de UnitID debe tener al menos un grupo First & last name Company name

15 String Externalization Pros and Cons
OASUS Spring or Fall YYYY Friday, November 16, 2018 String Externalization Pros and Cons Pros Minimum code maintenance Fallback mechanism Cons Setup itself cannot use the dataset First & last name Company name

16 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Resources Write Once, Run Anywhere! How to Make Your SAS Applications Speak Many Languages, Mickaël Bouedo, SGF paper SAS 9.3 National Language Support (NLS): Reference Guide. First & last name Company name

17 OASUS Spring or Fall YYYY
Friday, November 16, 2018 Demo Time First & last name Company name

18 OASUS Spring or Fall YYYY
Questions / Comments Friday, November 16, 2018 Lihsin Hwang System Engineering Division Statistics Canada (613) First & last name Company name


Download ppt "Make your SAS programs ready for any language"

Similar presentations


Ads by Google