BookmarkSubscribeRSS Feed
garag
Calcite | Level 5

Hi,

I'm getting problem reading Euro symbol € from exeternal file.

Here you are the code:

data mydatset;

            infile "&localfilename" delimiter=',' dsd missover firstobs=2;

            informat
              Date                      yymmdd10.
              Name               $100.

              ;

            format
              Date date9.;

            input
              Date
              Index_Name               $
              ;

          run;

If in my external file there is an Europ symbol (€), I can't get it in mydataset but a strange square is showed.

Any idea abou thow to fix it?

Many thanks

3 REPLIES 3
Tom
Super User Tom
Super User

The square is probably how your current character set displays that character. To see what actual ASCII code has been read from your file put the string using the $HEX format.  This will display each character as two hexadecimal digits representing the 8 bit code.  For example the digit zero is 30 in hex. The letter A is 41. The letter J is 4A.

Andre
Obsidian | Level 7

I have tried from a french excel 2010 saving in csv like this   but  my sas is also regulated in latin1 with french language.

My try with amounf countaining an euro formatted excel

saved in european csv where delimiter is = ;  as comma is the decimal separator  gives under ultraedit

euro symbol is represented in hex as 80  issued from excel2010

under ultraedit i saved too the csv file in utf8 encoding for my second try

and in both case in sas  this program  was correct   with the same result for both

code        but recall i am under a french version of sas 

so you may try with the encoding of euro exists too under iso8859-15 equivalent of latin9

data try1;

            infile "d:\temp\euro1.csv" delimiter=';' dsd missover firstobs=2;* encoding='latin9';

            informat

               Name       $10.  amount eurox10.2   Date     ddmmyy10.   ;

            format       Date date9.;

            input

              name $   amount   Date  ;

          run;

data try2;

            infile "d:\temp\euro1utf8.csv" delimiter=';' dsd missover firstobs=2  encoding='utf8';

            informat

            Name        $10.  amount eurox10.2       Date     ddmmyy10. ;

            format       Date date9.;

            input

              name $  amount   Date  ;

          run;

the other solution is applying a nls informat to a variable that is not well presenting

as some utf8 character was embedded inside  so perhaps:

x=input ( name, $utf8x10.);

HTH

Andre

Andre
Obsidian | Level 7

There is a new book at SAS

"Sas encoding  understanding the details "  by Manfred Kiefer   175 p

where the euro symbol is well mentionned as Latin9  !

http://support.sas.com/publishing/authors/kiefer.html

options locale=fr_FR; this options seems now from 9.3  accepted by  SAS Foundation

so if anybody  in the USA  can test my answer on an american version of SAS

it may be now more easier to treat those kind of difficulties  without the reserve i have presented in matter of encoding=

and after return to

options local=English_UnitedStates;

sorry but after reading more into the nls manual

the change of locale has only effect upon

dflang=    datestyle= and papersize=

sorry again you have to start sas with another encoding or make use of the encoding=   options in proc import, infile and so on

Andre

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 2723 views
  • 0 likes
  • 3 in conversation