Hi,
I am having an encoding problem with sas code files which is as follows:
The follwoing sas code is saved on a text file called "test_coding.sas" using SAS EG:
%macro test();
%put AVL und Kündigungausshaprachen Zusammenfuhren;
%mend;
When I recall the code as follows:
%include '....directory_Path\test_coding.sas';
%test();
The Output shown in LOG file has encoding problem. Here is the Output from LOG file:
%test();
AVL und K�ndigungausshaprachen Zusammenfuhren
The double code characters like "ü" are not read properly from the file 'test_coding.sas'.
Would be thankful for you Ideas.
regards
Check the encoding of the sas-program-file. Beginning with EG 7.11 you can select the encoding when saving code files, accessible via the small, black rectangle on the SAVE-Button - see screenshot. Using unicode should solve the problem.
What encoding does the SAS workspace server use?
It uses UTF-8 encoding.
Here are SAS options set in config file:
SAS session encoding or UTF-8 encoding.
DBCS Enables double-byte character sets for encoding East Asian languages.
DBCSLANG=UNKNOWN Specifies a double-byte character set language.
DBCSTYPE=UTF8 Specifies the encoding method to use for a double-byte character set.
ENCODING=UTF-8 Specifies the default character-set encoding for the SAS session.
LOCALE=DE_DE Specifies a set of attributes in a SAS session that reflect the language, local conventions, and culture for a
geographical region.
NONLSCOMPATMODE Encodes data using the SAS session encoding.
The Umlaut you used is encoded as hex FC (typical for wlatin/latin9 encoding), which is an invalid byte in Unicode. It works well when the SAS session runs with latin9 encoding (tested here). Did you type that code in Enterprise Guide, or did you copy/paste it from somewhere, or did you open existing code?
I type that code in Enterprise Guide, afterwords saved the code using Enterprise Guide as a sas text file.
When I source the the saved sas code on text file using "Include", I am obtaining this Umlaut coding problem.
Do you have an Idea how can I fix it ?
Do you save the code to your computer (My Documents/My Computer), or through Server/SASApp/Files? Saving it through the IOM bridge might mitigate the problem.
Otherwise, if you are running in a strictly non-Unicode environment (only Western/German characters needed), you can change the session encoding to latin9.
I save the code through Server/SASApp/Files.
Check the encoding of the sas-program-file. Beginning with EG 7.11 you can select the encoding when saving code files, accessible via the small, black rectangle on the SAVE-Button - see screenshot. Using unicode should solve the problem.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.