BookmarkSubscribeRSS Feed
SASdevAnneMarie
Barite | Level 11

Hello,

In my data file csv  have a lote of  "’", I need to replace it just by " ' ".

I import my row data file with infile statement (infile "&Rep_Travail\xxxx.csv" dsd truncover lrecl=32767 encoding=wlatin2) and I get the table donne.sas

 

When I run the code: 


data donnee_bis;
set donne;
var3_correct=tranwrd(var3,"’","'");
run;

 

I get the error that SAS "Failed to transcode data from U_UTF8_CE to LATIN_9_CE......."

 

I put already the options locale=FR before the infile. Maybe I need to change encoding option in infile statement?

Thank you for your help!

7 REPLIES 7
SASdevAnneMarie
Barite | Level 11

The data is attached.

Thank you

PGStats
Opal | Level 21

If your csv file was exported from an Excel workbook, you could correct the problem in Excel at the export step. In the export dialog, choose Tools - Web Options - Encoding -> Unicode (UTF-8)

PG
SASdevAnneMarie
Barite | Level 11
Thank you for your suggestion.
I'm receiving this file, I need to correct it automatically, not manually.
PGStats
Opal | Level 21

Then try adding option encoding=WLATIN1 to your infile statement.

PG
SASdevAnneMarie
Barite | Level 11
It doesn't work 😞
PGStats
Opal | Level 21

Maybe@Tom can help. He understands this encoding stuff.

PG
SASdevAnneMarie
Barite | Level 11
I mean that I import the file with encoding=wlatin1, but I still need to correct the values like :
VAR&i.=tranwrd(VAR&i.,"é","é");
VAR&i.=tranwrd(VAR&i.,"ÃŽ","ô");
VAR&i.=tranwrd(VAR&i.,"êŸ","ê");
VAR&i.=tranwrd(VAR&i.,"çŸ","ç");
VAR&i.=tranwrd(VAR&i.,"â","â");
VAR&i.=tranwrd(VAR&i.,"â€","'");
VAR&i.=tranwrd(VAR&i.,"Ã","à");
Maybe, there is some function as in this example (it doesn't work in my case 😞
data gg; g="Général";
g1=PUT(g,$UTF8x2000.);
g2=INPUT(g1,$UTF8x2000.);
run;
Obs g g1 g2

1 Général Général Général

I mean that with a step like that I don't need to use a lot of tranwrd functions, but I still can't found a combination of formats for my case...

Thank you very much!

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!
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
  • 7 replies
  • 826 views
  • 0 likes
  • 2 in conversation