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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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