<?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 Re: Reading XLS Inside ZIP in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604422#M175236</link>
    <description>&lt;P&gt;Have you seen the &lt;FONT face="courier new,courier"&gt;member=&lt;/FONT&gt; option?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lestmtsglobal&amp;amp;docsetTarget=n1dn0f61yfyzton1l2ngsa1clllr.htm&amp;amp;docsetVersion=9.4" target="_blank"&gt;https://documentation.sas.com/?docsetId=lestmtsglobal&amp;amp;docsetTarget=n1dn0f61yfyzton1l2ngsa1clllr.htm&amp;amp;docsetVersion=9.4&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Nov 2019 09:41:27 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-11-15T09:41:27Z</dc:date>
    <item>
      <title>Reading XLS Inside ZIP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604319#M175193</link>
      <description>&lt;P&gt;If there is a CSV file inside a ZIP file, for example, then we can directly import the data using a DATA step as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename have zip "!userprofile\desktop\have.zip";
data dataset;
infile have(filetoread.csv) dsd;
input year one two three;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The DATA step does not read an XLS file, so we need PROC IMPORT instead. Does PROC IMPORT provide something similar? Now I am using DATA _NULL_ with INFILE, FILE, INPUT, PUT, etc. to unzip first before reading but wonder whether there is a direct way to avoid unzipping and directly access inside.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604319#M175193</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-11-14T21:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XLS Inside ZIP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604422#M175236</link>
      <description>&lt;P&gt;Have you seen the &lt;FONT face="courier new,courier"&gt;member=&lt;/FONT&gt; option?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lestmtsglobal&amp;amp;docsetTarget=n1dn0f61yfyzton1l2ngsa1clllr.htm&amp;amp;docsetVersion=9.4" target="_blank"&gt;https://documentation.sas.com/?docsetId=lestmtsglobal&amp;amp;docsetTarget=n1dn0f61yfyzton1l2ngsa1clllr.htm&amp;amp;docsetVersion=9.4&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 09:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604422#M175236</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-11-15T09:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XLS Inside ZIP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604490#M175264</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173881"&gt;@Junyong&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If there is a CSV file inside a ZIP file, for example, then we can directly import the data using a DATA step as follows.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename have zip "!userprofile\desktop\have.zip";
data dataset;
infile have(filetoread.csv) dsd;
input year one two three;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The DATA step does not read an XLS file, so we need PROC IMPORT instead. Does PROC IMPORT provide something similar? Now I am using DATA _NULL_ with INFILE, FILE, INPUT, PUT, etc. to unzip first before reading but wonder whether there is a direct way to avoid unzipping and directly access inside.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Does the ZIP contain an XLS file or a CSV file?&amp;nbsp; You cannot read an XLS file with a data step.&amp;nbsp; It is a binary format.&amp;nbsp; You could read the CSV file.&amp;nbsp; Normally you would put quotes around the member name in your reference to the member of the aggregate storage location that the HAVE libref is pointing to.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile have("filetoread.csv") dsd;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also make sure that the file is not saved with a path in the ZIP file. If it is then you will need to include that path as part of the quoted name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 15:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604490#M175264</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-15T15:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XLS Inside ZIP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604496#M175267</link>
      <description>&lt;P&gt;Thanks for this comment, but it seems this code doesn't work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename down1 "%sysfunc(getoption(work))\download.zip";
proc http method="get" out=down1
url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_CSV.zip";
run;
filename down2 zip "%sysfunc(getoption(work))\download.zip" member="F-F_Research_Data_Factors.CSV";
proc import file=down2 dbms=csv out=data1 replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;PROC HTTP downloads down1 correctly, but PROC IMPORT fails to read down2 inside.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 15:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604496#M175267</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-11-15T15:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XLS Inside ZIP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604497#M175268</link>
      <description>&lt;P&gt;I think that PROC IMPORT has some quirk that makes it not work with members from a ZIP file.&lt;/P&gt;
&lt;P&gt;Try copying the file first.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename down1 "%sysfunc(getoption(work))\download.zip";
proc http method="get" out=down1
url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_CSV.zip";
run;
filename down2 zip "%sysfunc(getoption(work))\download.zip" member="F-F_Research_Data_Factors.CSV";
filename down3 temp;
data _null_;
  infile down2;
  file down3;
  input;
  put _infile_;
run;
proc import file=down3 dbms=csv out=data1 replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Nov 2019 15:17:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604497#M175268</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-15T15:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XLS Inside ZIP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604498#M175269</link>
      <description>&lt;P&gt;Thanks for this reply. I know DATA doesn't accept XLS, but wonder if PROC IMPORT can directly access to an XLS member file inside a ZIP file as DATA can.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 15:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604498#M175269</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-11-15T15:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Reading XLS Inside ZIP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604500#M175270</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/173881"&gt;@Junyong&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for this reply. I know DATA doesn't accept XLS, but wonder if PROC IMPORT can directly access to an XLS member file inside a ZIP file as DATA can.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Same answer:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I think that PROC IMPORT has some quirk that makes it not work with members from a ZIP file.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Although for a binary file like an XLS file you will need to use FILECOPY or some other method instead of the simple line by line copy that will work with a text file.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 15:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-XLS-Inside-ZIP/m-p/604500#M175270</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-15T15:39:56Z</dc:date>
    </item>
  </channel>
</rss>

