BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

Hello,

 

My windows is in French and I wonder if there is a way to avoid the at sign in an email address to be converted to a french character like this one: à

 

So if an client_email_address is like mike@hotmail.com it is converted to mikeàhotmail.com

Here's my piece of code;

 

Data test;

INFILE EBCDIC missover;

input

...

 

@2042 CLIENT_EMAIL_ADDRESS $EBCDIC71.

;

run;

37 REPLIES 37
jimbarbour
Meteorite | Level 14

This doesn't sound like a SAS issue per se.  It sounds like an encoding issue.  The $EBCDIC format is translating whatever the hexadecimal code is for an @ sign on the mainframe to what it thinks should be an @ sign in ASCII.  However, it looks like your Windows environment is translating that hexadecimal code to an à.  

 

The hexadecimal value for an @ sign is x'7C' in EBCDIC.  In your particular Windows environment, do you know what x'7C' is?  What is the hexadecimal code for an @ sign in your environment?

 

Jim

Tom
Super User Tom
Super User

What are the actual strings that are in the file?
Try reading the string using $CHAR informat and display some of the values with the $HEX format to see what hex code is in the file where the @ sign is.

 

Let us know what two digit hex code is in the file where the @ should be.

 

Also are you running this on an actual IBM mainframe?  Or did someone send you file from the mainframe? If the later then how was the file transferred to the machine where SAS is running? Are you sure the @ were not changed during the transfer?

 

PS Use TRUNCOVER instead of MISSOVER, especially when reading from fixed columns or using fixed length informats.

 

 

jimbarbour
Meteorite | Level 14

@alepage,

 

Would it be possible for you to run the below SAS code?  I don't need to know all the output, but I do want to know what the hexadecimal codes are for à, À, and @.

 

On my system, they are as follows:

 

Hex=40, Character=@
Hex=C0, Character=À
Hex=E0, Character=à

What are they in your environment?

 

 

Jim

 

Please run this code:

 

%LET	Null	=	;
%LET	sQuote	=	%STR(%');
%LET	dQuote	=	%STR(%");
%LET	Semi	=	%BQUOTE(;);
%LET	Nte2	=	NOTE-;

*%PUT	NOTE:  >%BQUOTE(&Semi)<;

DATA	_NULL_;
	ARRAY	Digits	{16}	$1	_TEMPORARY_	('0' '1' '2' '3' '4' '5' '6' '7' '8' '9' 'A' 'B' 'C' 'D' 'E' 'F');
	DO	_i	=	1	TO	16;
		CALL	SYMPUTX(CATS('Digit', STRIP(PUT(_i,2.))), Digits{_i}, 'G');
	END;
	STOP;
RUN;

&NULL	%MACRO	Generate_Hex_Displays;
	%LOCAL	i	j;

	%DO	i				=	1	%TO	16;
		%DO	j			=	1	%TO	16;
			Character = &sQuote.&&Digit&i&&Digit&j&sQuote.x&Semi PUTLOG &dQuote&Nte2  Hex=&&Digit&i&&Digit&j, &dQuote Character=&Semi
		%END;
	%END;
	%STR(PUTLOG	"&Nte2  ";);
%MEND	Generate_Hex_Displays;

%LET	PS_Save	=	%SYSFUNc(GETOPTION(PS));
OPTIONS	PS		=	MAX;

DATA	_NULL_;
	%UNQUOTE(%BQUOTE(%Generate_Hex_Displays));
	STOP;
RUN;

OPTIONS	PS		=	&PS_Save;

 

 

jimbarbour
Meteorite | Level 14

@alepage,

 

Did you get a chance to try running that code?  I just need the log output.  

 

That code will produce a lot of output.  I really only need three lines from the log.  If you haven't already run that code I posted previously, perhaps you could run this, below, and then post the log output?

OPTIONS	NOSOURCE;
%PUT	NOTE:  40 is %SYSFUNC(INPUTC(40, $HEX2.));
%PUT	NOTE-  C0 is %SYSFUNC(INPUTC(C0, $HEX2.));
%PUT	NOTE-  E0 is %SYSFUNC(INPUTC(E0, $HEX2.)); 
OPTIONS	SOURCE;

Jim

PhilC
Rhodochrosite | Level 12

Like 

&Null

@jimbarbour, you're teaching me something new every week!

jimbarbour
Meteorite | Level 14

@PhilC,

 

That's just a little colorization technique that I like.  I don't like losing colorization simply because I'm within a %macro - % mend

jimbarbour_0-1629127724719.png

 

And it's not that it just looks odd or I'm fundamentally opposed to the monochromatic; sometimes colorization will save you some aggravation.  🙂

jimbarbour_1-1629127904995.png

 

Here, I fumble fingered a "-" when I meant "=".  Yes, the above is a pretty trivial example, but sometimes, particularly if it's late, it may take me a bit to catch somethings, for example a "smart quote" (instead of a normal single quote) whereas with colorization I might spot it instantly.

jimbarbour_2-1629128588178.png

 

JIm

Tom
Super User Tom
Super User

Is that convoluted macro/non-macro mishmash code trying to do this?

data _null_;
  do byte=0 to 255;
    hex=put(byte,hex2.);
    character=input(hex,$hex2.);
    put hex= character=;
  end;
run;
jimbarbour
Meteorite | Level 14

@Tom

 

Thanks for the esthetic commentary.  🙂  Yes, both pieces of code do essentially the same thing.

 

Jim

alepage
Barite | Level 11

Hello,

Sorry for the delay.

Also, please note that I have an issue when I am trying to convert an EBCDIC file into a SAS format (spde) the @ is replace à in SAS EG.  I will have to test this code also on our unix server which could give other results.

 

 

 

Here's the content of the log file

 

1                                                          The SAS System                           10:28 Monday, September 13, 2021

 

1          ;*';*";*/;quit;run;

2          OPTIONS PAGENO=MIN;

3          %LET _CLIENTTASKLABEL='Programme';

4          %LET _CLIENTPROCESSFLOWNAME='Flux de processus';

5          %LET _CLIENTPROJECTPATH='';

6          %LET _CLIENTPROJECTPATHHOST='';

7          %LET _CLIENTPROJECTNAME='';

8          %LET _SASPROGRAMFILE='';

9          %LET _SASPROGRAMFILEHOST='';

10        

11         ODS _ALL_ CLOSE;

12         OPTIONS DEV=SVG;

13         GOPTIONS XPIXELS=0 YPIXELS=0;

14         %macro HTML5AccessibleGraphSupported;

15             %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;

16         %mend;

17         FILENAME EGHTML TEMP;

18         ODS HTML5(ID=EGHTML) FILE=EGHTML

19             OPTIONS(BITMAP_MODE='INLINE')

20             %HTML5AccessibleGraphSupported

21             ENCODING='utf-8'

22             STYLE=HTMLBlue

23             NOGTITLE

24             NOGFOOTNOTE

25             GPATH=&sasworklocation

26         ;

NOTE: Writing HTML5(EGHTML) Body file: EGHTML

27        

28         %LET      Null        =             ;

29         %LET      sQuote =             %STR(%');

30         %LET      dQuote =             %STR(%");

31         %LET      Semi      =             %BQUOTE(;);

32         %LET      Nte2      =             NOTE-;

33        

34         *%PUT  NOTE:  >%BQUOTE(&Semi)<;

35        

36         DATA     _NULL_;

37         ARRAY  Digits     {16}        $1           _TEMPORARY_ ('0' '1' '2' '3' '4' '5' '6' '7' '8' '9' 'A' 'B' 'C' 'D' 'E' 'F');

38         DO         _i            =             1             TO          16;

39                         CALL      SYMPUTX(CATS('Digit', STRIP(PUT(_i,2.))), Digits{_i}, 'G');

40         END;

41         STOP;

42         RUN;

 

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

     

 

43        

44         &NULL  %MACRO            Generate_Hex_Displays;

45         %LOCAL               i               j;

46        

47         %DO      i                                                              =             1              %TO      16;

48                         %DO      j                                              =             1              %TO      16;

49                                         Character = &sQuote.&&Digit&i&&Digit&j&sQuote.x&Semi PUTLOG &dQuote&Nte2  Hex=&&Digit&i&&Digit&j, &dQuote

49       ! Character=&Semi

50                         %END;

2                                                          The SAS System                           10:28 Monday, September 13, 2021

 

51         %END;

52         %STR(PUTLOG  "&Nte2  ";);

53         %MEND Generate_Hex_Displays;

54        

55         %LET      PS_Save              =             %SYSFUNc(GETOPTION(PS));

56         OPTIONS              PS                          =             MAX;

57        

58         DATA     _NULL_;

59          %UNQUOTE(%BQUOTE(%Generate_Hex_Displays));

60         STOP;

61         RUN;

 

       Hex=00, Character=

       Hex=01, Character=

       Hex=02, Character=

       Hex=03, Character=

       Hex=04, Character=

       Hex=05, Character=

       Hex=06, Character=

       Hex=07, Character=

       Hex=08, Character=

       Hex=09, Character=

       Hex=0A, Character=

       Hex=0B, Character=

       Hex=0C, Character=

       Hex=0D, Character=

       Hex=0E, Character=

       Hex=0F, Character=

       Hex=10, Character=

       Hex=11, Character=

       Hex=12, Character=

       Hex=13, Character=

       Hex=14, Character=

       Hex=15, Character=

       Hex=16, Character=

       Hex=17, Character=

       Hex=18, Character=

       Hex=19, Character=

       Hex=1A, Character=

       Hex=1B, Character=

       Hex=1C, Character=

       Hex=1D, Character=

       Hex=1E, Character=‑

       Hex=1F, Character=­

       Hex=20, Character=

       Hex=21, Character=!

       Hex=22, Character="

       Hex=23, Character=#

       Hex=24, Character=$

       Hex=25, Character=%

       Hex=26, Character=&

       Hex=27, Character='

       Hex=28, Character=(

       Hex=29, Character=)

       Hex=2A, Character=*

       Hex=2B, Character=+

       Hex=2C, Character=,

       Hex=2D, Character=-

       Hex=2E, Character=.

       Hex=2F, Character=/

       Hex=30, Character=0

       Hex=31, Character=1

       Hex=32, Character=2

       Hex=33, Character=3

       Hex=34, Character=4

       Hex=35, Character=5

       Hex=36, Character=6

       Hex=37, Character=7

       Hex=38, Character=8

       Hex=39, Character=9

       Hex=3A, Character=:

       Hex=3B, Character=;

       Hex=3C, Character=<

       Hex=3D, Character==

       Hex=3E, Character=>

       Hex=3F, Character=?

       Hex=40, Character=@

       Hex=41, Character=A

       Hex=42, Character=B

       Hex=43, Character=C

       Hex=44, Character=D

       Hex=45, Character=E

       Hex=46, Character=F

       Hex=47, Character=G

       Hex=48, Character=H

       Hex=49, Character=I

       Hex=4A, Character=J

       Hex=4B, Character=K

       Hex=4C, Character=L

       Hex=4D, Character=M

       Hex=4E, Character=N

       Hex=4F, Character=O

       Hex=50, Character=P

       Hex=51, Character=Q

       Hex=52, Character=R

       Hex=53, Character=S

       Hex=54, Character=T

       Hex=55, Character=U

       Hex=56, Character=V

       Hex=57, Character=W

       Hex=58, Character=X

       Hex=59, Character=Y

       Hex=5A, Character=Z

       Hex=5B, Character=[

       Hex=5C, Character=\

       Hex=5D, Character=]

       Hex=5E, Character=^

       Hex=5F, Character=_

       Hex=60, Character=`

       Hex=61, Character=a

       Hex=62, Character=b

       Hex=63, Character=c

       Hex=64, Character=d

       Hex=65, Character=e

       Hex=66, Character=f

       Hex=67, Character=g

       Hex=68, Character=h

       Hex=69, Character=i

       Hex=6A, Character=j

       Hex=6B, Character=k

       Hex=6C, Character=l

       Hex=6D, Character=m

       Hex=6E, Character=n

       Hex=6F, Character=o

       Hex=70, Character=p

       Hex=71, Character=q

       Hex=72, Character=r

       Hex=73, Character=s

       Hex=74, Character=t

       Hex=75, Character=u

       Hex=76, Character=v

       Hex=77, Character=w

       Hex=78, Character=x

       Hex=79, Character=y

       Hex=7A, Character=z

       Hex=7B, Character={

       Hex=7C, Character=|

       Hex=7D, Character=}

       Hex=7E, Character=~

       Hex=7F, Character=

       Hex=80, Character=€

       Hex=81, Character=

       Hex=82, Character=‚

       Hex=83, Character=ƒ

       Hex=84, Character=„

       Hex=85, Character=…

       Hex=86, Character=†

       Hex=87, Character=‡

       Hex=88, Character=ˆ

       Hex=89, Character=‰

       Hex=8A, Character=Š

       Hex=8B, Character=‹

       Hex=8C, Character=Œ

       Hex=8D, Character=

       Hex=8E, Character=Ž

       Hex=8F, Character=

       Hex=90, Character=

       Hex=91, Character=‘

       Hex=92, Character=’

       Hex=93, Character=“

       Hex=94, Character=”

       Hex=95, Character=•

       Hex=96, Character=–

       Hex=97, Character=—

       Hex=98, Character=˜

       Hex=99, Character=™

       Hex=9A, Character=š

       Hex=9B, Character=›

       Hex=9C, Character=œ

       Hex=9D, Character=

       Hex=9E, Character=ž

       Hex=9F, Character=Ÿ

       Hex=A0, Character= 

       Hex=A1, Character=¡

       Hex=A2, Character=¢

       Hex=A3, Character=£

       Hex=A4, Character=¤

       Hex=A5, Character=¥

       Hex=A6, Character=¦

       Hex=A7, Character=§

       Hex=A8, Character=¨

       Hex=A9, Character=©

       Hex=AA, Character=ª

       Hex=AB, Character=«

       Hex=AC, Character=¬

       Hex=AD, Character=­

       Hex=AE, Character=®

       Hex=AF, Character=¯

       Hex=B0, Character=°

       Hex=B1, Character=±

       Hex=B2, Character=²

       Hex=B3, Character=³

       Hex=B4, Character=´

       Hex=B5, Character=µ

       Hex=B6, Character=¶

       Hex=B7, Character=·

       Hex=B8, Character=¸

       Hex=B9, Character=¹

       Hex=BA, Character=º

       Hex=BB, Character=»

       Hex=BC, Character=¼

       Hex=BD, Character=½

       Hex=BE, Character=¾

       Hex=BF, Character=¿

       Hex=C0, Character=À

       Hex=C1, Character=Á

       Hex=C2, Character=Â

       Hex=C3, Character=Ã

       Hex=C4, Character=Ä

       Hex=C5, Character=Å

       Hex=C6, Character=Æ

       Hex=C7, Character=Ç

       Hex=C8, Character=È

       Hex=C9, Character=É

       Hex=CA, Character=Ê

       Hex=CB, Character=Ë

       Hex=CC, Character=Ì

       Hex=CD, Character=Í

       Hex=CE, Character=Î

       Hex=CF, Character=Ï

       Hex=D0, Character=Ð

       Hex=D1, Character=Ñ

       Hex=D2, Character=Ò

       Hex=D3, Character=Ó

       Hex=D4, Character=Ô

       Hex=D5, Character=Õ

       Hex=D6, Character=Ö

       Hex=D7, Character=×

       Hex=D8, Character=Ø

       Hex=D9, Character=Ù

       Hex=DA, Character=Ú

       Hex=DB, Character=Û

       Hex=DC, Character=Ü

       Hex=DD, Character=Ý

       Hex=DE, Character=Þ

       Hex=DF, Character=ß

       Hex=E0, Character=à

       Hex=E1, Character=á

       Hex=E2, Character=â

       Hex=E3, Character=ã

       Hex=E4, Character=ä

       Hex=E5, Character=å

       Hex=E6, Character=æ

       Hex=E7, Character=ç

       Hex=E8, Character=è

       Hex=E9, Character=é

       Hex=EA, Character=ê

       Hex=EB, Character=ë

       Hex=EC, Character=ì

       Hex=ED, Character=í

       Hex=EE, Character=î

       Hex=EF, Character=ï

       Hex=F0, Character=ð

       Hex=F1, Character=ñ

       Hex=F2, Character=ò

       Hex=F3, Character=ó

       Hex=F4, Character=ô

       Hex=F5, Character=õ

       Hex=F6, Character=ö

       Hex=F7, Character=÷

       Hex=F8, Character=ø

       Hex=F9, Character=ù

       Hex=FA, Character=ú

       Hex=FB, Character=û

       Hex=FC, Character=ü

       Hex=FD, Character=ý

       Hex=FE, Character=þ

       Hex=FF, Character=ÿ

      

NOTE: DATA statement used (Total process time):

      real time           0.02 seconds

      cpu time            0.03 seconds

     

 

62        

63         OPTIONS              PS                          =             &PS_Save;

3                                                          The SAS System                           10:28 Monday, September 13, 2021

 

64        

65         %LET _CLIENTTASKLABEL=;

66         %LET _CLIENTPROCESSFLOWNAME=;

67         %LET _CLIENTPROJECTPATH=;

68         %LET _CLIENTPROJECTPATHHOST=;

69         %LET _CLIENTPROJECTNAME=;

70         %LET _SASPROGRAMFILE=;

71         %LET _SASPROGRAMFILEHOST=;

72        

73         ;*';*";*/;quit;run;

74         ODS _ALL_ CLOSE;

75        

76        

77         QUIT; RUN;

78        

 

 

Tom
Super User Tom
Super User

From the printout of hex codes you generated you are running SAS on an ASCII host.

Where does the EBCDIC come from?

How did your SAS server get access to the file?

alepage
Barite | Level 11

The EBCDIC files are hosted on a Unix server

alepage
Barite | Level 11
more precisely using the command
filename EBCDIC "&SrcPath./&ebcdicfname." lrecl=3000 recfm=f;
Tom
Super User Tom
Super User

So you have a file on Unix.

So you can read the text from the file as binary data to see exactly what characters are in the file.

For example let me make a file with all 256 possible bytes.

filename ebcdic temp;
data _null_;
  file ebcdic recfm=f lrecl=256 encoding=any ;
  length string $256;
  string=collate(0,256);
  put string $char256.;
run;

Now to see what it in that file I can read and use LIST statement to dump it to the log.

data _null_;
  infile ebcdic recfm=f lrecl=256;
  input;
  list;
run;

You can to run a similar data step against your EBCDIC file and see what is actually stored there.

If the @ signs are already gone from that file then you need to figure out why the file was created with the wrong hex codes in those positions.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 37 replies
  • 1285 views
  • 5 likes
  • 6 in conversation