BookmarkSubscribeRSS Feed
ioannis
Fluorite | Level 6

Hi all,

 

I have a dataset in SAS (9.4) with a variable that reads with weird characters such as ÁÂÄÇÑÁ, the source language is Greek. When I change the font to "Greek" (right click on column, column attributes, fonts, data font, Script=Greek)  SAS reads the column in Greek language, which is great. However, the cell the values of the variable still contain weird names ÁÂÄÇÑÁ (I see this simply by clicking on a cell). As a result,  when I export the dataset in a txt file, the values still appear with the weird font. Is there a way to export the file in txt or csv or anything else that will use the Greek letters? No other source online can read these characters (ÁÂÄÇÑÁ) other than SAS, so since SAS can read Greek, there has to be a way to export it in Greek, right? 

 

I would really appreciate your help or any advice. Many thanks in advance. 

 

 

4 REPLIES 4
Tom
Super User Tom
Super User

What ENCODING are you using in your SAS session? To reliably use multiple languages you should be running using UTF-8 encoding.  That can handle Greek and other non 7bit ASCII character codes.  Note you still might need to use encoding to read your original file correctly if it is using single byte encoding with a codepage that supports interpretting some characters as meaning Greek glyphs.

 

If you write the text files using UTF-8 encoding then most other programs will recognize the characters without having the change the "font".

ioannis
Fluorite | Level 6

Thanks a lot for your response Tom. This is helpful, but doesn't solve my issue yet. 

 

Using utf-8 encoding doesn't work and gives me this error:  The file 'path\temp.txt' could not be opened. A byte-order mark indicates that the data is encoded in "utf-16le". This conflicts with the "utf-8" encoding that was specified for the fileref


Using utf-16 allows me to import the file, but it still does not change the format from weird symbols (ÁÃÉÏÓ ÌÕÑÙÍ) to Greek. You mentioned that I still need to use encoding to read the original file correctly it if is using single byte encoding. How do I do that? I have a simple file (see attached) and use the code below to import in the appropriate text. 


filename extfile 'path\temp.txt' encoding="utf-16" ;
data want;
infile extfile ;
input varname $30. ;
run;

Thanks so much again. 

Tom
Super User Tom
Super User
Your SESSION needs to be running using UTF-8 encoding, you have to set that when SAS starts.
Then you should be about to read the actual file using the encoding for that particular file and SAS will be able to transcode the characters into valid UTF-8 characters.
ioannis
Fluorite | Level 6

Thanks again Tom. I'm afraid even when I change the whole session (by chancing the sasv9.sfg file) it changes the encoding but it doesn't recognize Greek. That was the most confusing part. I tried every possible encoding online and none works for these characters. But when I change the font script in SAS then the text is correct. The problem is I can't replace the values in the column using the font script SAS is "superficially" using to display the Greek text. Many thanks again for checking with me.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1166 views
  • 1 like
  • 2 in conversation