DATA Step, Macro, Functions and more

SAS EG Encoding Problem: calling sas code using %Include

Accepted Solution Solved
Reply
Contributor
Posts: 38
Accepted Solution

SAS EG Encoding Problem: calling sas code using %Include

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

 


Accepted Solutions
Solution
‎08-31-2017 07:40 AM
Super Contributor
Posts: 345

Re: SAS EG Encoding Problem: calling sas code using %Include

Posted in reply to ehsanmath

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.

save.PNG

 

View solution in original post


All Replies
Super User
Posts: 7,809

Re: SAS EG Encoding Problem: calling sas code using %Include

Posted in reply to ehsanmath

What encoding does the SAS workspace server use?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 38

Re: SAS EG Encoding Problem: calling sas code using %Include

Posted in reply to KurtBremser

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.

 

Super User
Posts: 7,809

Re: SAS EG Encoding Problem: calling sas code using %Include

Posted in reply to ehsanmath

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?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 38

Re: SAS EG Encoding Problem: calling sas code using %Include

Posted in reply to KurtBremser

 

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 ?

 

Super User
Posts: 7,809

Re: SAS EG Encoding Problem: calling sas code using %Include

Posted in reply to ehsanmath

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 7,809

Re: SAS EG Encoding Problem: calling sas code using %Include

Posted in reply to ehsanmath

Otherwise, if you are running in a strictly non-Unicode environment (only Western/German characters needed), you can change the session encoding to latin9.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 38

Re: SAS EG Encoding Problem: calling sas code using %Include

Posted in reply to KurtBremser

 

I save the code through Server/SASApp/Files.

Solution
‎08-31-2017 07:40 AM
Super Contributor
Posts: 345

Re: SAS EG Encoding Problem: calling sas code using %Include

Posted in reply to ehsanmath

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.

save.PNG

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 164 views
  • 0 likes
  • 3 in conversation