BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Mayt
Quartz | Level 8

Hi, guys!

I've connect SAS to SQL server and tried  to write data to the server. But the Thai characters don't appear as I expected. They appear as "?".

 

More information:

The sqlserver running on windows.

SAS running on unix.

And the unicode of SAS session is UTF8.

 

How I connected SAS to SQL server

libname sslib sqlsvr noprompt="DRIVER=SAS ACCESS to MS SQL Server;
UID=my UID ;PWD=my Password;
HOST=my Host ;PORT=my Port ; db= my Database" schema="dbo";

the data

Mayt_1-1697538112231.png

If I create new table in SQL server from the data

proc sql;
	create table sslib.test_temp_output(encoding='utf8') as
	select *
	from work.temp_tbl(encoding='utf8');
run;

How a new table looks like:

Mayt_2-1697538283422.png

I've tried proc append but the results stay the same.

data _null_;
  set temp_tbl(encoding='any');
  put string= $quote. +1 string $hex8.;
run;

proc append base=sslib.test_table data=temp_tbl(encoding='utf8') ;
run;

or

data _null_;
  set temp_tbl(encoding='any');
  put string= $quote. +1 string $hex8.;
run;

proc append base=sslib.test_table data=temp_tbl(encoding='any') ;
run;

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
AhmedAl_Attar
Ammonite | Level 13

Hi @Mayt 

Have a look at this paper Multilingual Computing_with SAS 9.4

It looks like you would need to declare your SqlServer Tables with nchar/nvchar columns in order to display utf-8 data values.

 

Hope this helps,

Ahmed

View solution in original post

4 REPLIES 4
AhmedAl_Attar
Ammonite | Level 13

Hi @Mayt 

Have a look at this paper Multilingual Computing_with SAS 9.4

It looks like you would need to declare your SqlServer Tables with nchar/nvchar columns in order to display utf-8 data values.

 

Hope this helps,

Ahmed

Mayt
Quartz | Level 8

Can we do it in sas studio?

LinusH
Tourmaline | Level 20
Technically speaking yes, by using explicit SQL pass through.
Here's a Microsoft documentation link:
https://learn.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql?view=sql-serv...
Data never sleeps
Mayt
Quartz | Level 8
Thank you so much

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 4 replies
  • 3732 views
  • 4 likes
  • 3 in conversation