BookmarkSubscribeRSS Feed
Catrin
Obsidian | Level 7

Hello to everybody,

 

We need to send .csv data with national character data via email to our customer  in encoding  utf-8. We are working with SAS  9.4M4 on Linux.
The default encoding of the session is latin9. I am using Enterprise Guide 7.1 via terminal server.
My tests fail up to now. What I did is, to transcode the data from latin9 to utf-8. This works fine. But when using the .csv - file as attachment, the incoming email-attachment in Lotus Notes has lost the encoding  and also has lost data.

I control the resulting data in Ultraedit.

Please find my code attached  here. Any idea to solve the problem is very welcome. The testdat.csv just after creating is attached and also the data after sending via email as testdat_send.csv

/* creating data for test */
data testdat;
    input name :$10. ort :$10.;
    datalines;
Böger Hamm
Müller Münster
Änder Steinfurt
Münig Holdorf
Bäger Hamm
Mäller Münster
Ünder Steinfurt
Mänig Holdorf
Büger Hamm
Möller Münster
Önder Steinfurt
Mönig Holdorf
;
run;

/*transcoding data to utf-8 encoding*/

filename output '/u/m500381/testdat.csv' encoding="utf-8";
proc export data=testdat outfile=output dbms=csv;
    delimiter=';';
run;

/*Opening the data in Ultraedit shows correct encoding and  complete data */
/* Now sending data as attachment */
filename mailaus email to=('c.skamira@lvm.de') 
subject='CSV Attachment'
from='Catrin'
type='text/plain'
attach=('/u/m500381/testdat.csv' encoding='utf-8'  outencoding='utf-8' 
 );


data _null_;
   file mailaus;
   put 'Testdat UTF-8';
run;

/* the log seems to be ok */


NOTE: The file MAILAUS is:
      E-Mail Access Device

Message sent
      To:          'x.sssssssss@xx.de'
      Cc:          
      Bcc:         
      Subject:     CSV Attachment
      Attachments: ( '/u/m500381/testdat.csv' ENCODING = 'utf-8' OUTENCODING = 'utf-8' ) 
NOTE: 1 record was written to the file MAILAUS.
      The minimum record length was 13.
      The maximum record length was 13.
NOTE: DATA statement used (Total process time):
      real time           0.16 seconds
      cpu time            0.00 seconds


After sending the email,only this data are included in  .csv file:

name;ort
Böger;Hamm
Müller;Münster
Änder;Steinfurt

and Ultraedit shows encoding ISO-8859-1. The file has 50 bytes. Before sending the file has 195 bytes and Ultraedit shows utf-8 as encoding.

Kind regards
Catrin

4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
My recommendation is to open a track with Tech Support. Encoding issues can be tricky and if this is a production process, you want to get the most accurate help possible. That will come from Tech Support.
Cynthia
Catrin
Obsidian | Level 7

Hi Cynthia,

thank you for replying. We will act on your advice and get in contact with Tech Support.

Catrin

Patrick
Opal | Level 21

@Catrin 

Please let us know what SAS TechSupport advices.

 

My theory is that it's the email server and not SAS which changes things and that eventually defining a different mime type for the attachment will help (i.e. content_type set to something like text/csv inside the attach definition)

Catrin
Obsidian | Level 7

Hi  Patrick,

you were right, the email script is the location to change.


A colleague used the information here:

https://documentation.sas.com/?docsetId=hostunx&docsetTarget=p0raib8un6i57yn1funbemrct7wd.htm&docse...

to change  sending of .csv attachment with a  different script than smtp. Please see below how to change the program.

 

Kind regards Catrin

options emailsys="/sas94/SASFoundation/9.4/utilities/bin/sasm.elm.mime.utf8" ;

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!

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
  • 4 replies
  • 3299 views
  • 1 like
  • 3 in conversation