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

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