Allan Bowe
Allan Bowe

Reputation: 12691

Reasons for differences due to locale

One of the 'features' of the SAS Stored Process server is that the locale setting can change according to the context of the client. In my case, the session may be en_gb or en_us depending on whether the same request was sent by Excel or Chrome.

This can cause different results for the same report, eg when using ANYDTDTE. style informats. The quick fix is to explicitly set options locale=xxx;, but in order to gauge the significance of this it would be good to understand:

What are the main (non-cosmetic) ways in which the same program can give different results according to the session locale?

Upvotes: 3

Views: 101

Answers (1)

Joe
Joe

Reputation: 63424

The major ways that locale affects a program are in the character set/encoding and the date/time defaults.

Character set (or encoding) is determined in part by the locale, and can make a huge difference if one locale is something like en-us and one is utf8, for example. Not only will SAS often end up defaulting to the session encoding for reading in files (if they are not specified explicitly either in the program or the file's header), but how SAS can deal with characters once read into a SAS dataset changes. DBCS encodings will have two bytes storage per character, not one, and if the locale is en-us and you expect utf8 you may not be able to handle some characters that do not transcode between the two.

Date defaults are also highly relevant. en-gb likely assumes 10/8/2015 is August 10, 2015, while en-us assumes it is October 8, 2015. This is a good reason not to use anydtdte. when you can avoid it, of course. You can avoid issues with this by explicitly setting the DATESTYLE system option. You may also have some differences in default output formats, such as the separator in ddmmyy10. or similar.

To see the differences that are possible due to locale, see the documentation for the LOCALE system option. This mentions four settings:

  • DATESTYLE
  • DFLANG (similar to DATESTYLE, affects how dates are read)
  • ENCODING
  • PAPERSIZE

Also, TRANTAB is set as part of setting ENCODING.

Upvotes: 2

Related Questions