<?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: include the Keep= procedure when extracting a Zip file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824215#M325468</link>
    <description>&lt;P&gt;Thank you for your answer.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jul 2022 18:40:35 GMT</pubDate>
    <dc:creator>IdrissaO</dc:creator>
    <dc:date>2022-07-19T18:40:35Z</dc:date>
    <item>
      <title>include the Keep= procedure when extracting a Zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824139#M325433</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I want to read a zipped file. but the file is too big (about 400 variables). i just need some variables (20) in this file. is it possible to include the Keep= procedure when extracting the Zip file.&lt;BR /&gt;Here is the code I use :&lt;BR /&gt;filename inzip ZIP "D:\MesDonnee\BD_Prog_SAS\medecv2.zip";&lt;BR /&gt;filename laboHier "%sysfunc(getoption(work))/medecv2.sas7bdat" ;&lt;BR /&gt;data _NULL_;&lt;BR /&gt;infile inzip(medecv2.sas7bdat) lrecl=256 recfm=F length=length eof=eof unbuffered ;&lt;BR /&gt;file laboHier lrecl=256 recfm=N;&lt;BR /&gt;*to write the data generated by infile, i.e. cohort_Dm.sas7bdat;&lt;BR /&gt;input;&lt;BR /&gt;put _infile_ $varying256. length;&lt;BR /&gt;return;&lt;BR /&gt;eof:&lt;BR /&gt;stop;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 13:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824139#M325433</guid>
      <dc:creator>IdrissaO</dc:creator>
      <dc:date>2022-07-19T13:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: include the Keep= procedure when extracting a Zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824144#M325437</link>
      <description>&lt;P&gt;No.&lt;/P&gt;
&lt;P&gt;You have a ZIP file that contains a SAS dataset (.sas7bat).&lt;/P&gt;
&lt;P&gt;For SAS to be able to read the file it needs to be an actual file.&lt;/P&gt;
&lt;P&gt;So you need to first extract the file from the ZIP file into a physical dataset file.&amp;nbsp; If your WORK disk does not have enough room then expand it to some other disk.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then copy the variables you want into another SAS dataset and delete the extracted file.&lt;/P&gt;
&lt;P&gt;If the file is in the WORK library then just recreating it will delete the version copied from the ZIP file.&lt;/P&gt;
&lt;P&gt;Just list the variables you need in the KEEP= option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename inzip ZIP "D:\MesDonnee\BD_Prog_SAS\medecv2.zip"
   member="medecv2.sas7bdat" 
   recfm=f lrecl=256
;
filename laboHier "%sysfunc(getoption(work))/medecv2.sas7bdat" 
   recfm=f lrecl=256
;
%put Return code = %sysfunc(fcopy(inzip,labohier));
data medecv2;
  set medecv2(keep=var1 var2);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2022 15:30:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824144#M325437</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-19T15:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: include the Keep= procedure when extracting a Zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824154#M325442</link>
      <description>&lt;P&gt;Not during the zip extracting process - you need to expand the entire SAS data set file. Use a separate DATA step to create just the subset you need after extracting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;filename inzip ZIP "D:\MesDonnee\BD_Prog_SAS\medecv2.zip";
filename laboHier "%sysfunc(getoption(work))/medecv2.sas7bdat" ;
data _NULL_;
infile inzip(medecv2.sas7bdat) lrecl=256 recfm=F length=length eof=eof unbuffered ;
file laboHier lrecl=256 recfm=N;
*to write the data generated by infile, i.e. cohort_Dm.sas7bdat;
input;
put _infile_ $varying256. length;
return;
eof:
stop;
run;

data want;
 set medecv2(keep=var1-var20);
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 14:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824154#M325442</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-07-19T14:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: include the Keep= procedure when extracting a Zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824214#M325467</link>
      <description>&lt;P&gt;Thank you for your answer. In fact what made me ask the question is that it takes a lot of time to extract all the variables so I only need about 20.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 18:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824214#M325467</guid>
      <dc:creator>IdrissaO</dc:creator>
      <dc:date>2022-07-19T18:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: include the Keep= procedure when extracting a Zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824215#M325468</link>
      <description>&lt;P&gt;Thank you for your answer.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 18:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824215#M325468</guid>
      <dc:creator>IdrissaO</dc:creator>
      <dc:date>2022-07-19T18:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: include the Keep= procedure when extracting a Zip file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824220#M325473</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/426699"&gt;@IdrissaO&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your answer. In fact what made me ask the question is that it takes a lot of time to extract all the variables so I only need about 20.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The issue is that it takes a long time to do anything with a file that large.&amp;nbsp; If the data in the ZIP file was a text file, like a CSV file then you could write a data step that only creates the variables you need.&amp;nbsp; SAS does not need to first create a physical file to read a text file.&amp;nbsp; But the step would still have to READ the whole file. There is no way to read the 10th line without reading the 9 lines before it or to read the 10th value on a line without reading past the 9 values before it.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 18:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-the-Keep-procedure-when-extracting-a-Zip-file/m-p/824220#M325473</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-19T18:57:20Z</dc:date>
    </item>
  </channel>
</rss>

