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.
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.
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.
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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.