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

I have been stuck by this for several hours. I first tried

 

proc import datafile = "&path\example"
out = x
dbms = xlsx
replace;
getnames = yes;
run;

it can work, but the date variable is recognized as character. I also tried to save the excel file as csv, but Chinese characters will be missing. 

 

A small example data is attached.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

What encoding are you using in your SAS session?  Check the ENCODING option.  You should be using  UTF-8.

You need to start SAS with the right encoding setting if you want to be able to read multi-byte character sets.

 

But if your only issue is that your date variable is character then just convert it.

data want ;
  set have ;
  numdate = input(chardate,yymmdd10.);
  format numdate yymmdd10. ;
run;

Perhaps the things that look like hyphens between the parts of the date values are not really hyphens?  If so then you could remove them using COMPRESS() function.

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

What encoding are you using in your SAS session?  Check the ENCODING option.  You should be using  UTF-8.

You need to start SAS with the right encoding setting if you want to be able to read multi-byte character sets.

 

But if your only issue is that your date variable is character then just convert it.

data want ;
  set have ;
  numdate = input(chardate,yymmdd10.);
  format numdate yymmdd10. ;
run;

Perhaps the things that look like hyphens between the parts of the date values are not really hyphens?  If so then you could remove them using COMPRESS() function.

xyxu
Quartz | Level 8

Thanks for the reply! Yes, I was using SAS 9.4 (Chinese) version. I can use proc import and then convert chardate to date. However, when I sort nodupkey with Chinese-valued variables, the result messes up. 

 

Would this be caused by the length of these variables? One of them is $152. 

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
  • 3 replies
  • 1209 views
  • 1 like
  • 3 in conversation