PierreVanStulov
PierreVanStulov

Reputation: 425

How to change SAS session encoding dynamically

I am writing sas script which will work in batch. Encoding of SASApp session is UTF8 and all my tables (in Oracle database and SAS Datasets) has UTF8 encoding. BUT I have one compiled macro which can work with WCYRILLIC encoding only (it crashes with error if I use UTF8 as session encoding). This macro doesn't work with my tables, it performs some auxiliary actions.

The question is: how could I dynamically change session encoding from UTF8 to WCYRILLIC before the macro invoked and change it back to UTF8 just after it will be executed.

Upvotes: 0

Views: 1993

Answers (1)

user667489
user667489

Reputation: 9569

I don't think there is any way to change the session-level encoding option. The documentation page indicates that it can only be set when a session is first started:

Valid in: configuration file, SAS invocation

I think the best you can do is to override the session encoding option for every individual encoding-dependent statement in your problematic macro - i.e. specifying encoding=WCYRRLIC on every file, infile, filename, %include and ods statement generated by that macro.

Alternatively, if you have SAS/CONNECT you could write code that signs on to another session with encoding=WCYRILLIC specified in the invocation options just to run your macro, dumping the output back to the parent session.

Upvotes: 1

Related Questions