BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

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?

 

Ronein_0-1719825686339.png

 

3 REPLIES 3
rudfaden
Lapis Lazuli | Level 10

Probaly make the eecoding of your csv file and SAS session match.

Tom
Super User Tom
Super User

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;

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