Desktop productivity for business analysts and programmers

SAS Code in EG get garbled - UTF-8 encoding

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

SAS Code in EG get garbled - UTF-8 encoding

[ Edited ]

Hi Communities.

 

My code which saved in UTF-8 format get garbled when open in SAS EG. 

Capture.PNG

I googled and searched, but don't find any solution to solve this.

Besides, when open this code in SAS DM, it is displayed normally.


Accepted Solutions
Solution
‎05-03-2017 09:45 PM
Community Manager
Posts: 2,691

Re: SAS Code in EG get garbled - UTF-8 encoding

[ Edited ]

You can tell SAS Enterprise Guide to open a file with encoding.  File->Open->Program, and then in the file dialog there is a drop down menu on the Open button:

 

wenc.png

 

You'll be presented with a long list of possible encoding options.

 

Usually EG will detect the encoding automatically, but some editors don't always save the proper cues for others to pick it up.

View solution in original post


All Replies
Esteemed Advisor
Posts: 6,636

Re: SAS Code in EG get garbled

How did you save SAS code as UTF-8? .sas files are plain ASCII.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 11

Re: SAS Code in EG get garbled

Hi Kurt,

The code is developed in external editor using UTF-8 encoding.

Esteemed Advisor
Posts: 6,636

Re: SAS Code in EG get garbled


ChaseLiu wrote:

Hi Kurt,

The code is developed in external editor using UTF-8 encoding.


Why, in $DEITY's name? What's wrong with the SAS Enhanced Editor?

The fact that you have that problem clearly illustrates the error of your ways.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 11

Re: SAS Code in EG get garbled

SAS Enhanced Editor is too slow and outdated compared with those modern IDEs. Neither SAS EG could compare with it.

Besides, Many modern IDEs support customized function which great enchane the productivity.

I do not think it's the way that cause my problems. instead, it's the way SAS EG works.

I never encounter such a problem in traditional SAS.  

 

Esteemed Advisor
Posts: 6,636

Re: SAS Code in EG get garbled


ChaseLiu wrote:

SAS Enhanced Editor is too slow and outdated compared with those modern IDEs.

 


Grmmpf. Too slow? I've never experienced any delay when typing in the EE in EG (the Enhanced Editor in Base SAS and Enterprise Guide is the same, literally the same dll if you have local SAS). Any delay I get is when I send programs for execution over the network, and the runtime of code itself. And in what aspect is the EE "outdated"?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 11

Re: SAS Code in EG get garbled

What I said 'Slow', I mean developing code is slow.

I'm here to find a solution rather than argue with such a question. If you think SAS is not outdated, then be it.

Esteemed Advisor
Posts: 6,636

Re: SAS Code in EG get garbled

How did you open the code in SAS DM? Do you work across platforms (eg SAS with DM on UNIX, EG (naturally) on Windows)?

 

Seeing what you are doing in your code, one workaround (and significant improvement of the code) would be to store the lookup in a dataset, create a format dynamically from that, and use that format in a single put statement instead of that long if-then-else chain. That would remove the special UTF characters (which I guess are part of the strings) from the code.

 

And anytime you have a if-then-else chain, look at the select data step statement. Won't solve your immediate problem, but makes code more readable.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 11

Re: SAS Code in EG get garbled

Hi Kurt,

 

Thanks for your suggestion, I think your advice would be a work around. But I do not think this is a long-term solution.

What confused me a lot is that while I can open code normally in PC SAS but not in EG. This is very weird and I think there should have some ways to work out.

Super User
Super User
Posts: 6,315

Re: SAS Code in EG get garbled

Is there a setting in Enterprise Guide to tell it to use UTF-8 encoding?

Occasional Contributor
Posts: 11

Re: SAS Code in EG get garbled

This is exactly what I'm asking.

while I'm using EG in windows environment, it seems that EG default the encoding to windows default encoding.

Solution
‎05-03-2017 09:45 PM
Community Manager
Posts: 2,691

Re: SAS Code in EG get garbled - UTF-8 encoding

[ Edited ]

You can tell SAS Enterprise Guide to open a file with encoding.  File->Open->Program, and then in the file dialog there is a drop down menu on the Open button:

 

wenc.png

 

You'll be presented with a long list of possible encoding options.

 

Usually EG will detect the encoding automatically, but some editors don't always save the proper cues for others to pick it up.

Super User
Super User
Posts: 6,315

Re: SAS Code in EG get garbled

What version of EG does that menu appear? I do not see it in 6.1 M1HF5 (6.100.0.4180) (64-bit)

Community Manager
Posts: 2,691

Re: SAS Code in EG get garbled

Hi @Tom - it was added a long time ago, I think in EG 5.1.

 

2 step process depicted:

 

openwenc.png

SAS Super FREQ
Posts: 270

Re: SAS Code in EG get garbled

Are you opening your .sas program through your local file system or through the SAS server (Files location)?  Have you tried saving your .sas file in UTF-8 with a byte order mark (BOM) to see if that allows EG to discover the encoding?

☑ This topic is SOLVED.

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

Discussion stats
  • 17 replies
  • 209 views
  • 3 likes
  • 5 in conversation