<?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 Import SAS dataset from .zip file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568482#M160027</link>
    <description>&lt;P&gt;I am having difficulty trying to open a zipped SAS dataset. There seem to be very few examples of this that I can find online, and none of them offer a clue as to how to solve my problem.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I run the following code, I can see that SAS is successfully recognizing the zip file and its contents (I edited out the path for anonymity, but "path" in the below is a valid path to an existing directory on the machine):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename inzip ZIP "path\CoBISII-InterimAnalysis20190618.zip";

DATA contents(keep=memname);
 length memname $200;
 fid=dopen("inzip");
 if fid=0 then
  stop;
 memcount=dnum(fid);
 do i=1 to memcount;
  memname=dread(fid,i);
  output;
 end;
 rc=dclose(fid);
run;
 
PROC PRINT data=contents noobs N;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This produces the following output:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.CONTENTS" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;memname&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;mrsdata.sas7bdat&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Readme.xlsx&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="c linecontent"&gt;N = 2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to read the SAS dataset (mrsdata) into SAS. I tried following the example&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-sas/" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;and used the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename wc "%sysfunc(getoption(work))/mrsdata.sas7bdat";

DATA _null_;
	infile inzip(mrsdata.sas7bdat) lrecl=256 recfm=F length=length eof=eof unbuf;
	file wc lrecl=256 recfm=N;
	input;
	put _infile_ $varying256. length;
	return;
	eof:
	stop;
run;

PROC CONTENTS data=WORK.mrsdata;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, this produces the following error (again, I am editing out the path for anonymity's sake):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;ERROR: Open failure for path\CoBISII-InterimAnalysis20190618.zip during attempt to create a local file handle.&lt;BR /&gt;NOTE: UNBUFFERED is the default with RECFM=N.&lt;BR /&gt;NOTE: The file WC is:&lt;BR /&gt;Filename=C:\tmp\wc.dat,&lt;BR /&gt;RECFM=N,LRECL=256,File Size (bytes)=0,&lt;BR /&gt;Last Modified=24Jun2019:14:39:38,&lt;BR /&gt;Create Time=24Jun2019:14:39:38&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am at a complete loss as to how to proceed.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jun 2019 18:47:50 GMT</pubDate>
    <dc:creator>RyanSimmons</dc:creator>
    <dc:date>2019-06-24T18:47:50Z</dc:date>
    <item>
      <title>Import SAS dataset from .zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568482#M160027</link>
      <description>&lt;P&gt;I am having difficulty trying to open a zipped SAS dataset. There seem to be very few examples of this that I can find online, and none of them offer a clue as to how to solve my problem.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I run the following code, I can see that SAS is successfully recognizing the zip file and its contents (I edited out the path for anonymity, but "path" in the below is a valid path to an existing directory on the machine):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename inzip ZIP "path\CoBISII-InterimAnalysis20190618.zip";

DATA contents(keep=memname);
 length memname $200;
 fid=dopen("inzip");
 if fid=0 then
  stop;
 memcount=dnum(fid);
 do i=1 to memcount;
  memname=dread(fid,i);
  output;
 end;
 rc=dclose(fid);
run;
 
PROC PRINT data=contents noobs N;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This produces the following output:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.CONTENTS" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;memname&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;mrsdata.sas7bdat&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Readme.xlsx&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="c linecontent"&gt;N = 2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to read the SAS dataset (mrsdata) into SAS. I tried following the example&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-sas/" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;and used the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename wc "%sysfunc(getoption(work))/mrsdata.sas7bdat";

DATA _null_;
	infile inzip(mrsdata.sas7bdat) lrecl=256 recfm=F length=length eof=eof unbuf;
	file wc lrecl=256 recfm=N;
	input;
	put _infile_ $varying256. length;
	return;
	eof:
	stop;
run;

PROC CONTENTS data=WORK.mrsdata;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, this produces the following error (again, I am editing out the path for anonymity's sake):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;ERROR: Open failure for path\CoBISII-InterimAnalysis20190618.zip during attempt to create a local file handle.&lt;BR /&gt;NOTE: UNBUFFERED is the default with RECFM=N.&lt;BR /&gt;NOTE: The file WC is:&lt;BR /&gt;Filename=C:\tmp\wc.dat,&lt;BR /&gt;RECFM=N,LRECL=256,File Size (bytes)=0,&lt;BR /&gt;Last Modified=24Jun2019:14:39:38,&lt;BR /&gt;Create Time=24Jun2019:14:39:38&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am at a complete loss as to how to proceed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 18:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568482#M160027</guid>
      <dc:creator>RyanSimmons</dc:creator>
      <dc:date>2019-06-24T18:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Import SAS dataset from .zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568544#M160063</link>
      <description>&lt;P&gt;Your INFILE statement is missing quotes around the name of the member in the ZIP file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile inzip("mrsdata.sas7bdat")  ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jun 2019 20:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568544#M160063</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-24T20:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Import SAS dataset from .zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568787#M160190</link>
      <description>&lt;P&gt;I'm fairly certain that quotes there are not needed. There are plenty of &lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-sas/" target="_self"&gt;examples&lt;/A&gt; online that don't use the quotes and seem to work. Further, if I use the quotes with my example, I get the same exact error message, it doesn't change the behavior at all.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 14:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568787#M160190</guid>
      <dc:creator>RyanSimmons</dc:creator>
      <dc:date>2019-06-25T14:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Import SAS dataset from .zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568819#M160208</link>
      <description>&lt;P&gt;That is too bad that quoting wasn't the issue, would have been a trivial fix.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also try adding the member name to the FILENAME statement.&amp;nbsp; Use MEMBER="name".&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=n1dn0f61yfyzton1l2ngsa1clllr.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=n1dn0f61yfyzton1l2ngsa1clllr.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then it should be easier for you to use the FCOPY() function to extract the SAS7BDAT file.&amp;nbsp; See Example 2.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/viewer.htm#n10dz22b5ixohin1vwzilweetek0.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/viewer.htm#n10dz22b5ixohin1vwzilweetek0.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 15:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568819#M160208</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-25T15:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Import SAS dataset from .zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568854#M160223</link>
      <description>&lt;P&gt;Thanks for the suggestion. Unfortunately, I get the same error message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;rc=10005&lt;BR /&gt;msg=ERROR: Open failure for Z:\CRU\Pediatrics\Active Projects\CoBIS II\raw data\CoBISII-InterimAna&lt;BR /&gt;lysis20190618.zip during attempt to create a local file handle.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10005 is the error code returned by FCOPY; not sure if there is any meaning to be gleaned from that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do see that the documentation for FILENAME's ZIP access method states, "&lt;SPAN&gt;The ZIP access method reads and writes only files created with the WinZip file compression.&lt;/SPAN&gt;" I'm not sure how this .zip file was created, but I'm wondering if the issue was that it wasn't using WinZip.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 16:23:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568854#M160223</guid>
      <dc:creator>RyanSimmons</dc:creator>
      <dc:date>2019-06-25T16:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Import SAS dataset from .zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568857#M160225</link>
      <description>Make sure that the physical ZIP file can actually be seen by SAS.  Perhaps you have the path wrong. Or you have a path for a different machine than the machine that is running SAS.  Or perhaps the userid that is running the SAS code does not have access to the file.&lt;BR /&gt;Also make sure that you can read the ZIP file with some other utility. Perhaps you really do have a damaged file.&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Jun 2019 16:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Import-SAS-dataset-from-zip-file/m-p/568857#M160225</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-25T16:34:59Z</dc:date>
    </item>
  </channel>
</rss>

