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

Hello SAS Community!

 

I'm having an issue importing a csv file with data from different sites around the world.  If I don't set the encoding file to UTF-8 then my log is clean but the variable with the site name imports incorrectly.  When I set encoding to UTF-8 my site names look good, but the investigator name causes a WARNING to my log, which gets caught in my companies log checker.  I'm supposed to produce a clean log.  I created a sample csv file with 3 rows and 3 variables of data.

 

In my sample csv file it's the data in TestField1 that is causing the warning, and the variable TestField2 contains the site names that I need to be imported correctly.

 

Reading file without UTF-8...

proc import file="U:\sas\encoding_test.csv"
    out=csv_1
    dbms=csv
    replace;
    GUESSINGROWS = MAX;
run;

results in a dataset that looks like this...

ewod_1-1724027618975.png

 

Importing it with encoding set to UTF-8...

filename fname "U:\sas\encoding_test.csv" encoding="utf-8"  ;
proc import file=fname
    out=csv_2
    dbms=csv
    replace;
    GUESSINGROWS = MAX;
run;

Results in a data set that looks like this (correct TextField2, TextField1 is still not quite correct)...

ewod_2-1724027751932.png

The warning in the log looks like this:

ewod_3-1724028180875.png

 

TextField1 is a variable I don't use, so I'm not worried about it being read in correctly, I would just like a clean log.  I've attached my sample csv file (and this screenshot).

ewod_4-1724028435191.png

 

Any suggestions are appreciated.

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

If you are using UTF-8 encoding SAS, that would not be a problem.

 

Ksharp_0-1724031891484.png

Ksharp_1-1724031934543.png

 

View solution in original post

3 REPLIES 3
Ksharp
Super User

If you are using UTF-8 encoding SAS, that would not be a problem.

 

Ksharp_0-1724031891484.png

Ksharp_1-1724031934543.png

 

ewod
Calcite | Level 5

Thanks for the reply.  I am choosing my companies "Unicode Support" SAS session...

ewod_0-1724066495803.png

 

I'll check with my IT department and ask them to check the SAS install since it doesn't appear to be working properly.

 

Thanks again

whymath
Lapis Lazuli | Level 10
Your SAS session is not UTF-8 encoded, so the special characters "Çİ" can't be displayed normally even if you specify UTF-8 encoding to the file. That's why there is a transcoding——SAS can't display raw characters under the current session encoding.

You can import the file under UTF-8 encoded session, just like what @Ksharp does.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1456 views
  • 2 likes
  • 3 in conversation