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

Hallo,

I am trying to import a csv file. In this file the first line, the one containing the variables name, contains some names with utf-8 characters.

I'm working with SAS 9.4.

 

First try to import the code without considering the special characters using the "wlatin1" encoding.

filename P1 "C:\Temp\Test_UTF_8.csv" encoding='wlatin1';

proc import datafile=P1 dbms=csv replace out=raw;
delimiter=';';
run;

In this case the code is working but the columns containing the special characters like "ä".

 

When I try to change the encoding using "utf-8" 

filename P1 "C:\Temp\Test_UTF_8.csv" encoding='utf-8';

proc import datafile=P1 dbms=csv replace out=raw;
delimiter=';';
run;

the code is not working and I get the error:


ERROR: Invalid string.
FATAL: Unrecoverable I/O error detected in the execution of the DATA step program.
Aborted during the INITIALIZE EXECUTION phase.

 

 Has someone a solution to this problem or can give me an hint where to look.

Thanks a lot

 

Paolo

 

In attachment you find the file I'm trying to import and the log file.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You need a special option " options validvarname=any ".

 

options validvarname=any;
filename P1 "C:\Temp\Test_UTF_8.csv" encoding='wlatin1';
proc import datafile=P1 dbms=csv replace out=raw;
delimiter=';';
run;

View solution in original post

3 REPLIES 3
Ksharp
Super User

You need a special option " options validvarname=any ".

 

options validvarname=any;
filename P1 "C:\Temp\Test_UTF_8.csv" encoding='wlatin1';
proc import datafile=P1 dbms=csv replace out=raw;
delimiter=';';
run;
Tom
Super User Tom
Super User

Your file does not contain UTF-8 characters  In fact the extended ASCII characters it does have are using some of the values that UTF-8 uses to indicate multi-byte character encoding and that is what is causing the errors when you treat it as a UTF-8 encoded text.

 

Note since you are reading a text file you can just write your own data step to read the data.  Then you can control the variable names that will be used.

Paolo_Corti
Calcite | Level 5

Thank a lot for the answers! 

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 12147 views
  • 0 likes
  • 3 in conversation