<?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: Export zip files using ods in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431737#M281481</link>
    <description>&lt;P&gt;The fdelete() function expects a file reference, not a physical filename as argument.&lt;/P&gt;
&lt;P&gt;I used the example from the documentation as blueprint:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
fname = 'tempfile';
rc = filename(fname,"/srv/sas/data/sasexports/selligent/selligent_wait/snip_hkgzk_vie_&amp;amp;_file_prefix..csv");
if rc = 0 and fexist(fname) then rc = fdelete(fname);
put rc=;
rc = filename(fname);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 29 Jan 2018 11:37:27 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-01-29T11:37:27Z</dc:date>
    <item>
      <title>Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429058#M281468</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to zip csv files and export them on a specific location. I constantly get an error message that actually states that I'm trying to put the zip file on a location that doesn't exists, because 'I want' to export it on the path/[old file name]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does someone know what the solution for this is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the attachment you'll find the example of an export. Some paths or filenames are predefined.&lt;/P&gt;&lt;P&gt;In the error attachment you can find some info from the log, were it states that&amp;nbsp;&lt;SPAN&gt;'I want' to export it on the path/[old file name]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 09:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429058#M281468</guid>
      <dc:creator>PWS</dc:creator>
      <dc:date>2018-01-19T09:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429064#M281469</link>
      <description>&lt;P&gt;In this path from the ERROR messsage:&lt;/P&gt;
&lt;PRE&gt;/srv/sas/data/sasexports/selligent/selligent_wait/snip_hkgzk_vie_20180119.csv/expclang.snip_hkgzk_vie_export.zip&lt;/PRE&gt;
&lt;P&gt;you have&lt;/P&gt;
&lt;PRE&gt;snip_hkgzk_vie_20180119.csv&lt;/PRE&gt;
&lt;P&gt;which is usually the name of a file, not a directory.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 09:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429064#M281469</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-19T09:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429068#M281470</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you. This is also my question. I can't really see were I go wrong. Mostly because of the predefined path. So "&amp;amp;file_export_wait_s" is actually this path;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/srv/sas/data/sasexports/selligent/selligent_wait/&lt;/PRE&gt;&lt;P&gt;I don't understand why, when zipping the file, the original filename is added to the path...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 09:50:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429068#M281470</guid>
      <dc:creator>PWS</dc:creator>
      <dc:date>2018-01-19T09:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429069#M281471</link>
      <description>&lt;P&gt;This is your problem:&lt;/P&gt;
&lt;PRE&gt;archive_path="&amp;amp;file_export_wait_s"&lt;/PRE&gt;
&lt;P&gt;I bet that this macro variable contains&lt;/P&gt;
&lt;PRE&gt;/srv/sas/data/sasexports/selligent/selligent_wait/snip_hkgzk_vie_20180119.csv&lt;/PRE&gt;
&lt;P&gt;and not just a path, as you used it in the previous data _null_ step in the FILE statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;          
set expclang.&amp;amp;_file_name._export ;   
FILE  "&amp;amp;file_export_wait_s" lrecl=4000 DLM= ';' ; 
/*FILE  "&amp;amp;file_export_ready_s" lrecl=4000 DLM= ';' ; */
if _n_ = 1 then put @1 "CUSTOMER_ID;SUBJECTLINE;PREHEADER;REFERRER;FLEXBANNERS;GLOBALIDS;TEXTS;CONTENT";   
put (_all_) (~);
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That step would not work if the name in the FILE statement is a directory.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 10:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429069#M281471</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-19T10:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429082#M281472</link>
      <description>&lt;P&gt;Ohw, right. Of course. I just need to define the path again. Wow&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 11:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429082#M281472</guid>
      <dc:creator>PWS</dc:creator>
      <dc:date>2018-01-19T11:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429092#M281473</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183437"&gt;@PWS&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Ohw, right. Of course. I just need to define the path again. Wow&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Often it just takes another pair of eyes ...&lt;/P&gt;
&lt;P&gt;One of the reasons why forums like this are essential.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 12:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429092#M281473</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-19T12:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429093#M281474</link>
      <description>&lt;P&gt;One method to keep this from happening is to always separate path and file names:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let out_path=/srv/sas/data/sasexports/selligent/selligent_wait;
%let csv_out=snip_hkgzk_vie_20180119.csv;
%let zip_out=snip_hkgzk_vie_export.zip;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then you'd have&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set expclang.&amp;amp;_file_name._export;
file "&amp;amp;out_path./&amp;amp;out_csv." lrecl=4000 DLM= ';';

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods package(newzip) publish archive 
  properties(
   archive_name="&amp;amp;out_zip." 
   archive_path="&amp;amp;out_path."
  );
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jan 2018 12:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429093#M281474</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-19T12:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429135#M281475</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks. Still have some problems with zipping the file. I would expect to have the same zip file name as the csv file. So, with todays date. But somehow I'm not able to get it right. I need to automate the date, because, of course, it's different every day&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Besides that, it looks like the file isn't zipped at all, because the filesize of the zipped file is 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I now have this; see attachments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 14:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429135#M281475</guid>
      <dc:creator>PWS</dc:creator>
      <dc:date>2018-01-19T14:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429137#M281476</link>
      <description>&lt;P&gt;Resulting in this;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Zip files ftp.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17973i89FB775214A60E0B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Zip files ftp.PNG" alt="Zip files ftp.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 14:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429137#M281476</guid>
      <dc:creator>PWS</dc:creator>
      <dc:date>2018-01-19T14:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429271#M281477</link>
      <description>&lt;P&gt;I think it's cleaner when you use filerefs -- that point to the files you need -- instead of file paths/names in your ODS archive directives.&amp;nbsp; I &lt;A href="https://blogs.sas.com/content/sasdummy/2014/01/28/create-zip-ods-package/" target="_self"&gt;have an example in this article&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Complete code from my example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Change this to suit your environment */
%let projectDir = c:\projects\sgf2013\filenamezip;

/* Clean slate! */
filename newfile "&amp;amp;projectDir./carstats.zip";
data _null_;
  if (fexist('newfile')) then 
  	rc = fdelete('newfile');
run;
filename newfile clear;

/* Create folder if it doesn't exist */
options dlcreatedir;
libname out "&amp;amp;projectDir./data";

/* Create some data */
filename newcsv "&amp;amp;projectDir./data/pct.csv";
proc means noprint data=sashelp.cars;
var msrp;
output out=out.pct median=p50 p95=p95 p99=p99;
run;
ods csv file=newcsv;
proc print data=out.pct;
format _all_; /* clear the formats */
run;
ods csv close;

/* Create an informative document about this package */
filename rm "&amp;amp;projectDir./readme.rtf";
ods rtf(readme) 
  file="&amp;amp;projectDir./readme.rtf" style=Printer;
ods rtf(readme) 
  text="These are some instructions for what to do next";
proc datasets lib=out nolist;
contents data=pct;
quit;
ods rtf(readme) close;

/* Creating a ZIP file with ODS PACKAGE */
ods package(newzip) open nopf;
ods package(newzip) add file=newcsv path="data/";
ods package(newzip) add file=rm;
ods package(newzip) publish archive 
  properties(
   archive_name="carstats.zip" 
   archive_path="&amp;amp;projectDir."
  );
ods package(newzip) close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jan 2018 20:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/429271#M281477</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-01-19T20:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431718#M281478</link>
      <description>&lt;P&gt;I still have some problems deleting the original csv after it is zipped.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For debugging purpose I've written the whole directory.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Zipping the file works fine, but now I want to delete the original csv. I do not get an error message, but the csv is still there.&lt;/P&gt;&lt;P&gt;Could someone help?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 10:23:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431718#M281478</guid>
      <dc:creator>PWS</dc:creator>
      <dc:date>2018-01-29T10:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431720#M281479</link>
      <description>&lt;P&gt;&lt;STRONG&gt;DO NOT POST LOGS IN PICTURES!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Use the {i} icon and copy/paste the text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put rc=;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the data _null_ step to show the return code in the log.&lt;/P&gt;
&lt;P&gt;You are using just the filename in the fdelete() call, not the complete path, which is needed.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 10:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431720#M281479</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-29T10:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431730#M281480</link>
      <description>&lt;P&gt;This is the log;&lt;/P&gt;&lt;PRE&gt;161       +ods package(archived) open nopf;
162       +ods package(archived) add file="/srv/sas/data/sasexports/selligent/selligent_wait/snip_hkgzk_vie_&amp;amp;_file_prefix..csv";
163       +ods package(archived) publish archive
164       +properties(
165       +archive_name="snip_hkgzk_vie_&amp;amp;_file_prefix..zip"
166       +archive_path='/srv/sas/data/sasexports/selligent/selligent_wait/'
167       +);
NOTE: Writing zip package /srv/sas/data/sasexports/selligent/selligent_wait/snip_hkgzk_vie_20180129.zip.
168       +ods package(archived) close;
169       +data _null_;
170       +rc = fdelete ("/srv/sas/data/sasexports/selligent/selligent_wait/snip_hkgzk_vie_&amp;amp;_file_prefix..csv");
171       +put rc=;
172       +run;

NOTE: In a call to the FDELETE routine, the fileref /srv/sas/data/sasexports/selligent/selligent_wait/snip_hkgzk_vie_20180129.csv exceeds 8 characters, and will be truncated.
rc=20004
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jan 2018 10:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431730#M281480</guid>
      <dc:creator>PWS</dc:creator>
      <dc:date>2018-01-29T10:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431737#M281481</link>
      <description>&lt;P&gt;The fdelete() function expects a file reference, not a physical filename as argument.&lt;/P&gt;
&lt;P&gt;I used the example from the documentation as blueprint:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
fname = 'tempfile';
rc = filename(fname,"/srv/sas/data/sasexports/selligent/selligent_wait/snip_hkgzk_vie_&amp;amp;_file_prefix..csv");
if rc = 0 and fexist(fname) then rc = fdelete(fname);
put rc=;
rc = filename(fname);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jan 2018 11:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431737#M281481</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-29T11:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Export zip files using ods</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431754#M281482</link>
      <description>Thanks a lot!!</description>
      <pubDate>Mon, 29 Jan 2018 12:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-zip-files-using-ods/m-p/431754#M281482</guid>
      <dc:creator>PWS</dc:creator>
      <dc:date>2018-01-29T12:24:41Z</dc:date>
    </item>
  </channel>
</rss>

