BookmarkSubscribeRSS Feed
Gweeks
Fluorite | Level 6

Hi All,

 

I'm trying to write to a postgres database and I am getting the following error:

ERROR: CLI execute error: ERROR: invalid byte sequence for encoding "UTF8": 0x81; Error while executing the query.

 

I've added the PRESERVE_COL_NAMES options to my libname statement as well as the dquote option to my proc sql statement and I'm still getting the error.

 

Please help suggest other options to use. 

I've included the  proc sql code I used as well as the error message received.

 

Thank you for all your help.

 

proc sql dquote=ansi;
 create table pg_rep.activation_Rate_base as
 select * 
 from Factor_Base;
quit;

Gweeks_0-1621520537614.png

 

@Community_Help 

5 REPLIES 5
SASKiwi
PROC Star

Check your SAS session encoding using PROC OPTIONS:

proc options option = encoding;
run;

If it is different to UTF8 then this could be the cause of your error.

Gweeks
Fluorite | Level 6

The encoding of the SAS session is UTF-8.

Gweeks_0-1621548876997.png

 

 

Tom
Super User Tom
Super User

What is the definition of the pg_rep libref?

Is it using SAS base engine?
Some external database?

Gweeks
Fluorite | Level 6

It is an external database, PostgresSQl database

Kurt_Bremser
Super User

'81'x is a byte that must only appear as a continuation byte in UTF-8. Even in Windows 1252, it is not used.

I suggest you inspect your data to see where it appears. It might be you have binary coded values (e.g. a UUID stored in 16 bytes) that need to be translated with a DBSASTYPE option.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 5044 views
  • 0 likes
  • 4 in conversation