<?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 Is there a way to get compressed file sizes of entries in zip archive using ZIP filename engine? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-get-compressed-file-sizes-of-entries-in-zip/m-p/849700#M335884</link>
    <description>&lt;P&gt;I can get a list of files in a zip archive using DOPEN and DREAD.&amp;nbsp; However, when I try to MOPEN or FOPEN a compressed file, in order to use &lt;FONT face="lucida sans unicode,lucida sans"&gt;FINFO(id,"File size (bytes)")&lt;/FONT&gt;, the sysmsg() is "ERROR: Function execution error".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question: Is there a way to get the compressed sizes of the items in the zip file when using the ZIP engine?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let zipfile = c:\temp\ziptest\transp\archive1.zip;

data members(keep=filename label='Entries in the zip archive');
  length fref $8 filename $1000;

  rc = filename(fref,symget('zipfile'),'ZIP');
  msg = sysmsg();

  if rc ^= 0 then put msg;
  if rc = 0;

  did = dopen(fref);
  msg = sysmsg();

  if did = 0 then put msg;

  if did then 
    do index = 1 to dnum(did);
      filename = dread(did,index);
      output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then this step shows "ERROR: Function execution error"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set members;
  length fref_source $8 msg $200;
  rc1 = filename (fref_source, "&amp;amp;zipfile", "ZIP", "member=" || quote(trim(filename)) || " recfm=N lrecl=65536");
  put 'NOTE: ' rc1= fref_source=;&lt;BR /&gt;
  fid = fopen(fref_source);
  msg=sysmsg();
  put 'NOTE: FOPEN() ' fid= / msg;

  if fid then do;
    fsize_source = input(finfo(fid,'FILE SIZE (BYTES)'),best.);
    fid = fclose(fid);
  end;
  put fsize_source=;

  if rc1 = 0 then rc = filename (fref_source);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 14 Dec 2022 17:27:56 GMT</pubDate>
    <dc:creator>RichardDeVen</dc:creator>
    <dc:date>2022-12-14T17:27:56Z</dc:date>
    <item>
      <title>Is there a way to get compressed file sizes of entries in zip archive using ZIP filename engine?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-get-compressed-file-sizes-of-entries-in-zip/m-p/849700#M335884</link>
      <description>&lt;P&gt;I can get a list of files in a zip archive using DOPEN and DREAD.&amp;nbsp; However, when I try to MOPEN or FOPEN a compressed file, in order to use &lt;FONT face="lucida sans unicode,lucida sans"&gt;FINFO(id,"File size (bytes)")&lt;/FONT&gt;, the sysmsg() is "ERROR: Function execution error".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question: Is there a way to get the compressed sizes of the items in the zip file when using the ZIP engine?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let zipfile = c:\temp\ziptest\transp\archive1.zip;

data members(keep=filename label='Entries in the zip archive');
  length fref $8 filename $1000;

  rc = filename(fref,symget('zipfile'),'ZIP');
  msg = sysmsg();

  if rc ^= 0 then put msg;
  if rc = 0;

  did = dopen(fref);
  msg = sysmsg();

  if did = 0 then put msg;

  if did then 
    do index = 1 to dnum(did);
      filename = dread(did,index);
      output;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then this step shows "ERROR: Function execution error"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set members;
  length fref_source $8 msg $200;
  rc1 = filename (fref_source, "&amp;amp;zipfile", "ZIP", "member=" || quote(trim(filename)) || " recfm=N lrecl=65536");
  put 'NOTE: ' rc1= fref_source=;&lt;BR /&gt;
  fid = fopen(fref_source);
  msg=sysmsg();
  put 'NOTE: FOPEN() ' fid= / msg;

  if fid then do;
    fsize_source = input(finfo(fid,'FILE SIZE (BYTES)'),best.);
    fid = fclose(fid);
  end;
  put fsize_source=;

  if rc1 = 0 then rc = filename (fref_source);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Dec 2022 17:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-get-compressed-file-sizes-of-entries-in-zip/m-p/849700#M335884</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2022-12-14T17:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to get compressed file sizes of entries in zip archive using ZIP filename engine?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-get-compressed-file-sizes-of-entries-in-zip/m-p/849718#M335893</link>
      <description>&lt;P&gt;You can use FINFO with some special attributes to get the info. See &lt;A href="https://blogs.sas.com/content/sasdummy/2017/09/08/filename-zip-details/" target="_self"&gt;this article for an example&lt;/A&gt;. Here's a snippet:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;fId = fopen("&amp;amp;f","S");
if fID then
  do;
   infonum=foptnum(fid);
     do i=1 to infonum;
      infoname=foptname(fid,i);
      select (infoname);
       when ('Filename') filename=finfo(fid,infoname);
       when ('Member Name') membername=finfo(fid,infoname);
       when ('Size') filesize=input(finfo(fid,infoname),15.);
       when ('Compressed Size') compressedsize=input(finfo(fid,infoname),15.);
       when ('CRC-32') crc32=finfo(fid,infoname);
       when ('Date/Time') filetime=input(finfo(fid,infoname),anydtdtm.);
      end;    
   end;
 compressedratio = compressedsize / filesize;
 output;
 fId = fClose( fId );&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 19:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-get-compressed-file-sizes-of-entries-in-zip/m-p/849718#M335893</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-12-14T19:07:36Z</dc:date>
    </item>
  </channel>
</rss>

