<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Writing MS Office and other binary files in Microsoft Integration with SAS</title>
    <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27168#M529</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
At my presentation on using the DATA Step as a POP3 mail client somebody asked how to deal with attachments. For text-based attachments that is no problem. Binary files are more complicated. First you have to decode them (back from Base64 to binary) and then file them. Decoding is a piece of cake, but the filing part is giving me a headache. I could not open it.&lt;BR /&gt;
&lt;BR /&gt;
Then I tried to read an Excel file (*.xls) and write it out again, just with INPUT; PUT _INFILE_; I could not open the copied file, although in the properties it looks identical (at least in byte count).&lt;BR /&gt;
Next I did a comparison by reading the original file and the copy file and compare them byte by byte. No difference to see.&lt;BR /&gt;
&lt;BR /&gt;
So I assume that there are certain hidden elements in those binary files that are not read or rewritten in this process. &lt;BR /&gt;
&lt;BR /&gt;
Any suggestion what I might be missing and how to solve it?</description>
    <pubDate>Mon, 04 May 2009 21:54:17 GMT</pubDate>
    <dc:creator>ErikT</dc:creator>
    <dc:date>2009-05-04T21:54:17Z</dc:date>
    <item>
      <title>Writing MS Office and other binary files</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27168#M529</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
At my presentation on using the DATA Step as a POP3 mail client somebody asked how to deal with attachments. For text-based attachments that is no problem. Binary files are more complicated. First you have to decode them (back from Base64 to binary) and then file them. Decoding is a piece of cake, but the filing part is giving me a headache. I could not open it.&lt;BR /&gt;
&lt;BR /&gt;
Then I tried to read an Excel file (*.xls) and write it out again, just with INPUT; PUT _INFILE_; I could not open the copied file, although in the properties it looks identical (at least in byte count).&lt;BR /&gt;
Next I did a comparison by reading the original file and the copy file and compare them byte by byte. No difference to see.&lt;BR /&gt;
&lt;BR /&gt;
So I assume that there are certain hidden elements in those binary files that are not read or rewritten in this process. &lt;BR /&gt;
&lt;BR /&gt;
Any suggestion what I might be missing and how to solve it?</description>
      <pubDate>Mon, 04 May 2009 21:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27168#M529</guid>
      <dc:creator>ErikT</dc:creator>
      <dc:date>2009-05-04T21:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Writing MS Office and other binary files</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27169#M530</link>
      <description>please post your code ...</description>
      <pubDate>Tue, 05 May 2009 14:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27169#M530</guid>
      <dc:creator>Bill</dc:creator>
      <dc:date>2009-05-05T14:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Writing MS Office and other binary files</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27170#M531</link>
      <description>This is the code I used for copying:&lt;BR /&gt;
&lt;BR /&gt;
filename orig 'e:\sgf2009\test1.xls' recfm=v lrecl=32767 ignoredoseof;&lt;BR /&gt;
filename copy 'e:\sgf2009\test2.xls' recfm=v lrecl=32767 ignoredoseof;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
infile orig ;&lt;BR /&gt;
input; &lt;BR /&gt;
file copy;&lt;BR /&gt;
put _infile_;&lt;BR /&gt;
run;&lt;BR /&gt;
filename  orig clear;&lt;BR /&gt;
filename  copy clear;&lt;BR /&gt;
&lt;BR /&gt;
I think the problem is that the filename statement does not handle the file attribute settings under windows and I don't see any options by which I could set them.&lt;BR /&gt;
Although the contents of the files is identical, the properties windows are not. The original shows 3 tabs (General, Custom, Summary), the copy shows only one (General)&lt;BR /&gt;
&lt;BR /&gt;
rgds Erik</description>
      <pubDate>Tue, 05 May 2009 15:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27170#M531</guid>
      <dc:creator>ErikT</dc:creator>
      <dc:date>2009-05-05T15:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Writing MS Office and other binary files</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27171#M532</link>
      <description>how about &lt;BR /&gt;
&lt;BR /&gt;
data _null_;                                                                                                                            &lt;BR /&gt;
  call system ('copy c:\temp\Orig.xls c:\temp\Copy.xls');                                                                               &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
?</description>
      <pubDate>Tue, 05 May 2009 15:57:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27171#M532</guid>
      <dc:creator>Bill</dc:creator>
      <dc:date>2009-05-05T15:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Writing MS Office and other binary files</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27172#M533</link>
      <description>Yes, but that does not solve my problem.&lt;BR /&gt;
&lt;BR /&gt;
The final step is not the copy, that was only a test, trying to figure out what went wrong.&lt;BR /&gt;
&lt;BR /&gt;
The idea is to decode and file a BASE64 mail attachment. So I need to do it in a DATA step.</description>
      <pubDate>Tue, 05 May 2009 17:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27172#M533</guid>
      <dc:creator>ErikT</dc:creator>
      <dc:date>2009-05-05T17:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Writing MS Office and other binary files</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27173#M534</link>
      <description>and this option doesn't work for you?&lt;BR /&gt;
&lt;BR /&gt;
  attach=("c:\temp\test.xls"&lt;BR /&gt;
          ct="application/octet-stream");</description>
      <pubDate>Wed, 06 May 2009 13:31:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27173#M534</guid>
      <dc:creator>Bill</dc:creator>
      <dc:date>2009-05-06T13:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: Writing MS Office and other binary files</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27174#M535</link>
      <description>Bill,&lt;BR /&gt;
&lt;BR /&gt;
I have given up on finding out why the  copying did not work, but I have been able to reach my original goal: converting a BASE64 encoded file into its original binary status.&lt;BR /&gt;
&lt;BR /&gt;
If you want to do it in a DATA step, with FILE and PUT statements, the trick is that you have to write them as one continuous data stream. To do that you define a logical record length which is bigger than the biggest attachment you are handling. I tried LRECL of more than 1 MB and you use a trailing @ in the PUT statement.&lt;BR /&gt;
&lt;BR /&gt;
The alternative is to use an external program like base64.exe and use a CALL SYSTEM to execute it.&lt;BR /&gt;
&lt;BR /&gt;
Thanks to your interest in the matter!</description>
      <pubDate>Sun, 10 May 2009 21:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Writing-MS-Office-and-other-binary-files/m-p/27174#M535</guid>
      <dc:creator>ErikT</dc:creator>
      <dc:date>2009-05-10T21:56:43Z</dc:date>
    </item>
  </channel>
</rss>

