BookmarkSubscribeRSS Feed
singhsahab
Lapis Lazuli | Level 10

Hi All,


While creating the table into oracle database by PROC SQL/Data step statement i'm getting "-" symbol got converted into "–" special character. Can anyone please suggest how to prevent the conversion.


Original Data is in SAS datasets is : "Infections - Viral Hepatitis - New or worsening"

After loading data into Oracle database it will become "Infections - Viral Hepatitis – New or worsening"


Currently i'm using INENCODING=ANY OUTENCODING=ANY options with Libname statement.


When using INENCODING='UTF-8' OUTENCODING='UTF-8' options with libname then getting below error..


SAS Studio
ERROR: Some character data was lost during transcoding in the dataset TEST. Either the data contains characters that are not
representable in the new encoding or truncation occurred during transcoding.

Thank you in advance.

6 REPLIES 6
SuryaKiran
Meteorite | Level 14

Did you check what encoding is your SAS and Oracle.

 

For SAS run: proc options option=encoding; run;

For Oracle run : select * from nls_database_parameters where parameter = 'NLS_CHARACTERSET';

 

 Make sure you have the right encoding for both.

Thanks,
Suryakiran
singhsahab
Lapis Lazuli | Level 10

Hi Surya,

 

Thank you for your suggestion. I check and found my SAS 9.4 default encoding is "WLATIN1" and my oracle DB default encoding UTF-8.

Can you please suggest how to convert encoding WLATIN1 to UTF-8 . i used outencoding options with libname statement but getting the same error as earlier. 

 

Please let me know if any other suggestion to pervert the conversion.

 

Many Thanks,

A.K 

andreas_lds
Jade | Level 19

Some chars in UTF-8 can't be converted to WLatin1, those chars are causing the trouble. Imho changing the encoding of the sas session is the only way to solve the issue. Session encoding can only be changed in the sas servers config files.

SuryaKiran
Meteorite | Level 14

You might have the UTF-8 PC SAS, Open Windows>All Progrms>SAS>SAS unicode uft8. Open this and work from here. 

 

Also these might help:

http://support.sas.com/kb/51/586.html

http://support.sas.com/kb/15/597.html

Thanks,
Suryakiran
Ksharp
Super User

Make SAS and Oracle has the same encoding.

Check sasenv_local file .

 

OR

OUTENCODING='WLATIN1' 

 

WLATIN1 is your sas encoding. use this code check:

proc options option=encoding;run;

LoriGoldman
Obsidian | Level 7

I transferred a SAS dataset from our Linux server to my Windows 10 laptop.  I've struggled trying to read this file using SAS 9.4 on my laptop.  

 

I ran the following code in EG on the server to determine that the encoding on the server is UTF-8.

proc options option=encoding; run;

 

I opened SAS 9.4 with Unicode Support and ran the following code

libname lib_in 'path to dir with file from server' inencoding='UTF-8';
libname lib_out 'path to save copy of file from server' outencoding=any;

data lib_in.dsn;
set lib_out.dsn;
run;

 

This code ran error free.  Then I opened "normal" SAS 9.4 on my laptop and accessed the lib_out.dsn file successfully using the same libname option as above.  

 

This worked for me.

Lori

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
  • 6 replies
  • 6824 views
  • 0 likes
  • 5 in conversation