Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Reading Euro symbol from external file

Reply
Contributor
Posts: 58

Reading Euro symbol from external file

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

Super User
Super User
Posts: 6,498

Re: Reading Euro symbol from external file

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.

Super Contributor
Posts: 273

Re: Reading Euro symbol from external file

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

Super Contributor
Posts: 273

Re: Reading Euro symbol from external file

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

Ask a Question
Discussion stats
  • 3 replies
  • 1025 views
  • 0 likes
  • 3 in conversation