Hello
I wan to import CSV Excel file.
The file is saved as type cv comma delimited.
I am using import wizard and receive an error.
What should I do in order to solve it and import the file?
Probaly make the eecoding of your csv file and SAS session match.
Use the Copy Files task to upload the file, then write the DATA step yourself with ENCODING=UTF8 in the INFILE statement.
The message means that the file is using UTF-8 characters and your SAS session is running with a single byte encoding that does not have any way to represent some of the UTF-8 characters that are in the file.
If you run SAS using UTF-8 encoding instead then the import Wizard should work.
Otherwise upload the file to the machine where SAS is actually running and just read it yourself. If you still want to use a single byte encoding the read the file using ENCODING='ANY' option in the INFILE statement. You can then use functions like KCVT, HTMLENCODE() and TRANWRD to convert the UTF-8 characters that are not included in your single byte encoding into multiple character strings.
For example here is an example of how to convert UTF-8 characters in a variable that are not valid in LATIN1 into multiple character strings that HTML will recognize as those same characters.
*----------------------------------------------------------------------------;
* Convert any extended or control characters to HTML strings ;
*----------------------------------------------------------------------------;
array _character_ _character_;
do over _character_;
do until(_n_=0);
_n_=kverify(_character_,collate(0,127)||kcvt(collate(128,255),'latin1','utf-8'));
if _n_ then _character_=tranwrd(_character_,ksubstr(_character_,_n_,1)
,htmlencode(ksubstr(_character_,_n_,1),'7bit'))
;
end;
end;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.