I'm trying to import excel file in .xls format to SAS using code:
PROC IMPORT out=WORK.test
DATAFILE='/place/where/file.xls'
DBMS=xls REPLACE;
sheet='name';
getnames=YES;
mixed=no;
RUN;
I need to use encoding='UTF-8' to replace some symbols in different columns.
How should I write this code to get right result?
filename x '/place/where/file.xls' encoding='utf-8'; PROC IMPORT out=WORK.test DATAFILE=x DBMS=xls REPLACE; sheet='name'; getnames=YES; mixed=no; RUN;
Thanks, but it doesn't work. Symbols like � stay.
Then Save this xls file into CSV file . and try import again .
@J_J_J wrote:
Thanks, but it doesn't work. Symbols like � stay.
Interesting. When importing text-files that contain unicode-chars which aren't in the active session encoding (Latin1 on our server), sas writes an error/warning to the log and removes the char from the string. I am wondering why sas inserts fancy chars when reading an excel file containing unicode chars.
Oh. I just be ware of that you need change your sas session into UTF-8 encoding as well to make � appeared.
I had similar issues when retrieving data from external origin into SAS_UE, though it is predefined with encoding='utf-8' .
I found that enlarging LENGTH of specific variables was the solution.
Thanks to everybody. None of the proposed options unfortunately helped. The problem was solved only by changing the format of the file from .xls to .xlsx, fortunately it was possible.
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!
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.