<?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 Determine if a data set exists in either zipped or unzipped state in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Determine-if-a-data-set-exists-in-either-zipped-or-unzipped/m-p/790299#M40156</link>
    <description>&lt;P&gt;I'm leveraging the SAS support article found here:&amp;nbsp;&lt;A href="https://support.sas.com/kb/24/670.html" target="_blank" rel="noopener"&gt;https://support.sas.com/kb/24/670.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'm trying to adapt the provided code to do a second '%if %sysfunc(exist(....' check for a zipped version of the same data set. I'm thinking like a GZIP file with a '.sas7bdat.gz' extension. Basically if the data exists (and is not zipped) do A, if the data exists (but is zipped) do B, or if the data exists in neither the zipped nor the non-zipped formats then do C.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried several different versions of the statement within the second 'exist()' statement, but I can't seem to get it right because in an instance where I should get a '1' in the log from the %put &amp;amp;need_to_unzip.;' statement, I'm keep getting the 'Data set &amp;amp;dsn. does not exist' statement back like it isn't checking the zipped option correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried&amp;nbsp;&amp;nbsp;&lt;CODE class=""&gt;exist(&amp;amp;dsn.gz),&amp;nbsp;exist(&amp;amp;dsn..gz),&amp;nbsp;exist(&amp;amp;dsn.sas7bdat.gz),&amp;nbsp;and exist(&amp;amp;dsn..sas7bdat.gz)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;I'm&amp;nbsp;thinking&amp;nbsp;I&amp;nbsp;need&amp;nbsp;some&amp;nbsp;sort&amp;nbsp;of&amp;nbsp;function&amp;nbsp;or&amp;nbsp;statement&amp;nbsp;to&amp;nbsp;indicate&amp;nbsp;to&amp;nbsp;SAS&amp;nbsp;that&amp;nbsp;it&amp;nbsp;should&amp;nbsp;be&amp;nbsp;a&amp;nbsp;zip&amp;nbsp;file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro checkds(dsn);
   %if %sysfunc(exist(&amp;amp;dsn)) %then %do;
      proc print data = &amp;amp;dsn;
      run;
   %end;
   %else %if %sysfunc(exist(&amp;amp;dsn.gz)) %then %do;
      %let need_to_unzip = 1;
      %put &amp;amp;need_to_unzip.;
   %end;
   %else %do;
      data _null_;
         file print;
         put #3 @10 "Data set &amp;amp;dsn. does not exist";
      run;
   %end;
%mend checkds;

%checkds(mylibrary.mytable)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jan 2022 23:16:11 GMT</pubDate>
    <dc:creator>proc_talk</dc:creator>
    <dc:date>2022-01-14T23:16:11Z</dc:date>
    <item>
      <title>Determine if a data set exists in either zipped or unzipped state</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Determine-if-a-data-set-exists-in-either-zipped-or-unzipped/m-p/790299#M40156</link>
      <description>&lt;P&gt;I'm leveraging the SAS support article found here:&amp;nbsp;&lt;A href="https://support.sas.com/kb/24/670.html" target="_blank" rel="noopener"&gt;https://support.sas.com/kb/24/670.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'm trying to adapt the provided code to do a second '%if %sysfunc(exist(....' check for a zipped version of the same data set. I'm thinking like a GZIP file with a '.sas7bdat.gz' extension. Basically if the data exists (and is not zipped) do A, if the data exists (but is zipped) do B, or if the data exists in neither the zipped nor the non-zipped formats then do C.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried several different versions of the statement within the second 'exist()' statement, but I can't seem to get it right because in an instance where I should get a '1' in the log from the %put &amp;amp;need_to_unzip.;' statement, I'm keep getting the 'Data set &amp;amp;dsn. does not exist' statement back like it isn't checking the zipped option correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried&amp;nbsp;&amp;nbsp;&lt;CODE class=""&gt;exist(&amp;amp;dsn.gz),&amp;nbsp;exist(&amp;amp;dsn..gz),&amp;nbsp;exist(&amp;amp;dsn.sas7bdat.gz),&amp;nbsp;and exist(&amp;amp;dsn..sas7bdat.gz)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;I'm&amp;nbsp;thinking&amp;nbsp;I&amp;nbsp;need&amp;nbsp;some&amp;nbsp;sort&amp;nbsp;of&amp;nbsp;function&amp;nbsp;or&amp;nbsp;statement&amp;nbsp;to&amp;nbsp;indicate&amp;nbsp;to&amp;nbsp;SAS&amp;nbsp;that&amp;nbsp;it&amp;nbsp;should&amp;nbsp;be&amp;nbsp;a&amp;nbsp;zip&amp;nbsp;file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro checkds(dsn);
   %if %sysfunc(exist(&amp;amp;dsn)) %then %do;
      proc print data = &amp;amp;dsn;
      run;
   %end;
   %else %if %sysfunc(exist(&amp;amp;dsn.gz)) %then %do;
      %let need_to_unzip = 1;
      %put &amp;amp;need_to_unzip.;
   %end;
   %else %do;
      data _null_;
         file print;
         put #3 @10 "Data set &amp;amp;dsn. does not exist";
      run;
   %end;
%mend checkds;

%checkds(mylibrary.mytable)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 23:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Determine-if-a-data-set-exists-in-either-zipped-or-unzipped/m-p/790299#M40156</guid>
      <dc:creator>proc_talk</dc:creator>
      <dc:date>2022-01-14T23:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if a data set exists in either zipped or unzipped state</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Determine-if-a-data-set-exists-in-either-zipped-or-unzipped/m-p/790310#M40157</link>
      <description>&lt;P&gt;I don't think the EXIST function will work with zipped datasets as EXIST requires the use of the LIBNAME statement and AFAIK there is no ZIP option for a SAS library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, there is a &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsglobal/n1dn0f61yfyzton1l2ngsa1clllr.htm#p0ev6qrbgvl7p3n148timdyxob68" target="_blank" rel="noopener"&gt;ZIP method&lt;/A&gt; for the FILENAME statement. You could then use FEXIST to check if either the ZIP file or the member of a ZIP file exists. This won't tell you if it is a valid SAS dataset or not but at least you can unzip it if it exists and then maybe try EXIST.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jan 2022 00:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Determine-if-a-data-set-exists-in-either-zipped-or-unzipped/m-p/790310#M40157</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-01-15T00:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Determine if a data set exists in either zipped or unzipped state</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Determine-if-a-data-set-exists-in-either-zipped-or-unzipped/m-p/790313#M40158</link>
      <description>&lt;P&gt;You are using two level name to reference that SAS dataset, mylib.mydataset, so you will need to figure out what filename that should be.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let libref=%scan(work.&amp;amp;dsn,-2,.);
%let path=%sysfunc(pathname(&amp;amp;libref));
%let fname=&amp;amp;path/%sysfunc(lowcase(%scan(&amp;amp;dsn,-1,.))).sas7bdat.gz;
%if %sysfunc(fileexist(&amp;amp;fname))%then %do;
  %put Found a GZIP version of the file at &amp;amp;=fname ;
....
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Jan 2022 01:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Determine-if-a-data-set-exists-in-either-zipped-or-unzipped/m-p/790313#M40158</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-15T01:53:30Z</dc:date>
    </item>
  </channel>
</rss>

