<?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 to put files in zip file in macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728181#M28263</link>
    <description>&lt;P&gt;Thank you it worked - in my folder I willl get the CSV files seperate from the ZIP files - is there any way to ONLY have ZIP files in the folder?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Mar 2021 13:47:11 GMT</pubDate>
    <dc:creator>mmea</dc:creator>
    <dc:date>2021-03-22T13:47:11Z</dc:date>
    <item>
      <title>How to put files in zip file in macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728147#M28258</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I Where can I add that in this macro?&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 14:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728147#M28258</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-03-22T14:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to put files in zip file in macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728151#M28259</link>
      <description>&lt;P&gt;Like that?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro prefix(code);

proc datasets;
delete tabel1-tabel5;
quit;

/*tabel 1*/

proc sql;
create table tabel1 as select 
datetime() as dateformat ymdhms.,
lab,
ID,
from test
quit;

/*tabel2*/

proc sql;
create table tabel2 as select date format ymd., 
from test2
quit;

/*tabel3*/

proc sql;
create table tabel3 as select 
date format ymdhms.,
ID, 
CODE,
TESTED
from test3
quit;

/*tabel 4*/

data tabel4;
set test4;
format Dato ymd.;
run;

/*tabel 5 */

data tabel5;
set test5;
run;


%do i=1 %to 5;

proc export data=tabel&amp;amp;i. replace
  outfile="&amp;amp;out_folder.\&amp;amp;code._COVID19_TABLE&amp;amp;i._&amp;amp;YYYYMMDD..csv"
  dbms=dlm
;
delimiter=';';
quit;

/* try this ****/
filename in "&amp;amp;out_folder.\&amp;amp;code._COVID19_TABLE&amp;amp;i._&amp;amp;YYYYMMDD..csv" lrecl=1 recfm=n;
filename out "&amp;amp;out_folder.\&amp;amp;code..zip" member = "&amp;amp;code._COVID19_TABLE&amp;amp;i._&amp;amp;YYYYMMDD..csv" lrecl=1 recfm=n;

data _null_;
  rc = fcopy("in", "out");
  if rc ne 0 then 
    put "ERROR: for file &amp;amp;code._COVID19_TABLE&amp;amp;i._&amp;amp;YYYYMMDD..csv";
run;

filename in clear;
filename out clear;
/***************/
%end;
%mend;

%macro dummy_macro();
%if &amp;amp;nobs ne 4 %then %do; 

filename mymail email from='test@test.dk' to=&amp;amp;mailto.
         subject='ERROR -'
         attach=("&amp;amp;logpath.&amp;amp;YYYYMMDD._log.log");

%end;
%else %do;

%prefix(1);
%prefix(2);
%prefix(3);
%prefix(4);
%prefix(5);

filename mymail email from='test@test.dk' to=&amp;amp;mailto.
         subject='success';

ods listing file="&amp;amp;out_folder.\tesxtfile.txt";
data _null_;
    file print;
    text="The files has been uploaded succesfully";
    put text;
run;
ods listing close;


%end;
%mend;

%dummy_macro();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 12:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728151#M28259</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-03-22T12:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to put files in zip file in macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728171#M28261</link>
      <description>&lt;P&gt;It says&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR 23-2: Invalid option name member.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 13:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728171#M28261</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-03-22T13:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to put files in zip file in macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728173#M28262</link>
      <description>&lt;P&gt;Sorry, should be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out ZIP "&amp;amp;out_folder.\&amp;amp;code..zip" member = "&amp;amp;code._COVID19_TABLE&amp;amp;i._&amp;amp;YYYYMMDD..csv" lrecl=1 recfm=n;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;B&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 13:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728173#M28262</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-03-22T13:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to put files in zip file in macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728181#M28263</link>
      <description>&lt;P&gt;Thank you it worked - in my folder I willl get the CSV files seperate from the ZIP files - is there any way to ONLY have ZIP files in the folder?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 13:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728181#M28263</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2021-03-22T13:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to put files in zip file in macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728186#M28264</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* try this */
filename out ZIP "&amp;amp;out_folder.\&amp;amp;code..zip" member = "&amp;amp;code._COVID19_TABLE&amp;amp;i._&amp;amp;YYYYMMDD..csv" lrecl=1 recfm=n;

proc export data=tabel&amp;amp;i. replace
  outfile=out
  dbms=dlm
;
delimiter=';';
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and drop my code between:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* try this ****/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/***************/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If it fails, the try to replace data step from my code with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  rc = fcopy("in", "out");
  if rc ne 0 then 
    put "ERROR: for file &amp;amp;code._COVID19_TABLE&amp;amp;i._&amp;amp;YYYYMMDD..csv";
  else fdelete("in");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All the best&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>Mon, 22 Mar 2021 13:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-put-files-in-zip-file-in-macro/m-p/728186#M28264</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-03-22T13:57:42Z</dc:date>
    </item>
  </channel>
</rss>

