<?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: How do I export a newly created text file to a zip file? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671164#M201507</link>
    <description>&lt;P&gt;Post the full log will help. But since you're using time and date, my guess is that the time doesn't match exactly anymore. If you run it a minute later your file will have a different name so you cannot use dynamic time references when you need to do something list. I would suggest creating the filename once and then using it through the process.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let file_export = &amp;amp;ExportLoc./finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123;


proc export data=finaldata
outfile= "&amp;amp;file_export..txt"
dbms=dlm replace;
delimiter='|';
run;

ods package(newzip) open nopf;
ods package(newzip) add file="&amp;amp;file_export..txt";
ods package(newzip) publish archive
properties(
archive_name="&amp;amp;file_export..zip"
archive_path="&amp;amp;ExportLoc."
);
ods package(newzip) close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121262"&gt;@InspectahDex&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc export data=finaldata&lt;BR /&gt;outfile="&amp;amp;ExportLoc./finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123.txt"&lt;BR /&gt;dbms=dlm replace;&lt;BR /&gt;delimiter='|';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to take what is created from there to export out into a zipped file. I have the below code but the log says it can't find the physical file because it doesn't exist. What am I missing?&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;ods package(newzip) open nopf;&lt;BR /&gt;ods package(newzip) add file="&amp;amp;ExportLoc./finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123.txt";&lt;BR /&gt;ods package(newzip) publish archive&lt;BR /&gt;properties(&lt;BR /&gt;archive_name="finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123.zip"&lt;BR /&gt;archive_path="&amp;amp;ExportLoc."&lt;BR /&gt;);&lt;BR /&gt;ods package(newzip) close;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jul 2020 18:19:54 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-07-21T18:19:54Z</dc:date>
    <item>
      <title>How do I export a newly created text file to a zip file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671130#M201496</link>
      <description>&lt;P&gt;I have this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc export data=finaldata&lt;BR /&gt;outfile="&amp;amp;ExportLoc./finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123.txt"&lt;BR /&gt;dbms=dlm replace;&lt;BR /&gt;delimiter='|';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to take what is created from there to export out into a zipped file. I have the below code but the log says it can't find the physical file because it doesn't exist. What am I missing?&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;ods package(newzip) open nopf;&lt;BR /&gt;ods package(newzip) add file="&amp;amp;ExportLoc./finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123.txt";&lt;BR /&gt;ods package(newzip) publish archive&lt;BR /&gt;properties(&lt;BR /&gt;archive_name="finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123.zip"&lt;BR /&gt;archive_path="&amp;amp;ExportLoc."&lt;BR /&gt;);&lt;BR /&gt;ods package(newzip) close;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 17:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671130#M201496</guid>
      <dc:creator>InspectahDex</dc:creator>
      <dc:date>2020-07-21T17:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export a newly created text file to a zip file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671164#M201507</link>
      <description>&lt;P&gt;Post the full log will help. But since you're using time and date, my guess is that the time doesn't match exactly anymore. If you run it a minute later your file will have a different name so you cannot use dynamic time references when you need to do something list. I would suggest creating the filename once and then using it through the process.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let file_export = &amp;amp;ExportLoc./finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123;


proc export data=finaldata
outfile= "&amp;amp;file_export..txt"
dbms=dlm replace;
delimiter='|';
run;

ods package(newzip) open nopf;
ods package(newzip) add file="&amp;amp;file_export..txt";
ods package(newzip) publish archive
properties(
archive_name="&amp;amp;file_export..zip"
archive_path="&amp;amp;ExportLoc."
);
ods package(newzip) close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121262"&gt;@InspectahDex&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc export data=finaldata&lt;BR /&gt;outfile="&amp;amp;ExportLoc./finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123.txt"&lt;BR /&gt;dbms=dlm replace;&lt;BR /&gt;delimiter='|';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to take what is created from there to export out into a zipped file. I have the below code but the log says it can't find the physical file because it doesn't exist. What am I missing?&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;ods package(newzip) open nopf;&lt;BR /&gt;ods package(newzip) add file="&amp;amp;ExportLoc./finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123.txt";&lt;BR /&gt;ods package(newzip) publish archive&lt;BR /&gt;properties(&lt;BR /&gt;archive_name="finaldata_%sysfunc(today(),yymmddN.)%sysfunc(hour(%sysfunc(time())),z2.)%sysfunc(minute(%sysfunc(time())),z2.)%sysfunc(second(%sysfunc(time())),z2.)_123.zip"&lt;BR /&gt;archive_path="&amp;amp;ExportLoc."&lt;BR /&gt;);&lt;BR /&gt;ods package(newzip) close;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 18:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671164#M201507</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-21T18:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export a newly created text file to a zip file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671170#M201511</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about by using filename ZIP? By the way I suggest you to use proc format to have "easier" file naming:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Assuming we have this: */
%let ExportLoc = %sysfunc(pathname(work));

data finaldata;
  set sashelp.class;
run;


/* to make naming textfie easier! */
proc format; 
  picture  myDatetime (default=14)
    other='%Y%0m%0d%0H%0M%0S' (datatype=datetime)
  ;
run;


/* reference to ZIP device */
filename f ZIP "&amp;amp;ExportLoc./newzip.zip" member = "finaldata_%sysfunc(datetime(), myDatetime.)_123.txt";
proc export data=finaldata
    outfile=f
    dbms=dlm 
    replace;
  delimiter='|';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 18:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671170#M201511</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-07-21T18:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export a newly created text file to a zip file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671201#M201521</link>
      <description>Thank you! That worked and solved my problem! Also thanks for the proc format tip!</description>
      <pubDate>Tue, 21 Jul 2020 20:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671201#M201521</guid>
      <dc:creator>InspectahDex</dc:creator>
      <dc:date>2020-07-21T20:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export a newly created text file to a zip file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671203#M201522</link>
      <description>&lt;P&gt;Because the code will be part of an automated process, I need to do this all in one step without having to run the entire program twice.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 20:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671203#M201522</guid>
      <dc:creator>InspectahDex</dc:creator>
      <dc:date>2020-07-21T20:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I export a newly created text file to a zip file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671259#M201548</link>
      <description>You should not have to run my solution twice. &lt;BR /&gt;&lt;BR /&gt;The issue with your solution is a matter of timing. If you run it at 11:59:58 (11:59AM) the text file has the 59 as minutes. If the next step is run at 12:00:01 (12:00PM) you'll have 00 as the minutes so that file doesn't exist. So you need to create the filename once and fix it, not calculate it dynamically throughout your code. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Jul 2020 01:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-export-a-newly-created-text-file-to-a-zip-file/m-p/671259#M201548</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-22T01:46:51Z</dc:date>
    </item>
  </channel>
</rss>

