BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

Hello,

I am downloading an xml file from an api website. Then I am creating a mapfile but I getting conversion errors due to the presence of emoji into the xml file.

I have used a perl script to remove the emoji from the xml file, but now, I am getting these  errors:

 

ERROR: The creation of the XML Mapper file failed.
ERROR: Error in the LIBNAME statement.

 

/********** Creating the map file ***************/

%let file_path=/finsys/...;
%let xmlFile2=VirageSurvey.xml;
%let xmlMap2=VirageSurvey.map;

%put &=file_path.;
%put &=xmlFile2.;
%put &=&xmlMap2.;

filename datafile "&file_path./&xmlFile2." encoding='utf-8';
%put %sysfunc(pathname(datafile));
filename mapfile "&file_path./&xmlMap2.";
%put %sysfunc(pathname(mapfile));

libname datafile xmlv2 automap=replace xmlmap=mapfile compat=yes;

What's can be done to solve this issue.

3 REPLIES 3
andreas_lds
Jade | Level 19

Should work, if the sas session uses utf-8 encoding.

alepage
Barite | Level 11
Is there a way to check if the UTF8 encoding is effective. Can we add more options to help in the troubleshooting
Tom
Super User Tom
Super User

It is probably more important to make sure your SAS session is using UTF-8 than it is to tell SAS what encoding to use for individual files.  SAS can usually detect the encoding of a file it is reading. But if the session is not using UTF-8 encoding and you try to read in a character from an UTF-8 encoded file that is not one of the 256 characters that exist in the singly byte encoding you are using to run SAS then it can cause loss of data (or worse).

 

To check if SAS is running with UTF-8 encoding check the value of the ENCODING system option.  You could use PROC OPTIONS.

proc options option=encoding;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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