Hi
I Where can I add that in this macro?
Like that?
%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&i. replace
outfile="&out_folder.\&code._COVID19_TABLE&i._&YYYYMMDD..csv"
dbms=dlm
;
delimiter=';';
quit;
/* try this ****/
filename in "&out_folder.\&code._COVID19_TABLE&i._&YYYYMMDD..csv" lrecl=1 recfm=n;
filename out "&out_folder.\&code..zip" member = "&code._COVID19_TABLE&i._&YYYYMMDD..csv" lrecl=1 recfm=n;
data _null_;
rc = fcopy("in", "out");
if rc ne 0 then
put "ERROR: for file &code._COVID19_TABLE&i._&YYYYMMDD..csv";
run;
filename in clear;
filename out clear;
/***************/
%end;
%mend;
%macro dummy_macro();
%if &nobs ne 4 %then %do;
filename mymail email from='test@test.dk' to=&mailto.
subject='ERROR -'
attach=("&logpath.&YYYYMMDD._log.log");
%end;
%else %do;
%prefix(1);
%prefix(2);
%prefix(3);
%prefix(4);
%prefix(5);
filename mymail email from='test@test.dk' to=&mailto.
subject='success';
ods listing file="&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();
Bart
Like that?
%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&i. replace
outfile="&out_folder.\&code._COVID19_TABLE&i._&YYYYMMDD..csv"
dbms=dlm
;
delimiter=';';
quit;
/* try this ****/
filename in "&out_folder.\&code._COVID19_TABLE&i._&YYYYMMDD..csv" lrecl=1 recfm=n;
filename out "&out_folder.\&code..zip" member = "&code._COVID19_TABLE&i._&YYYYMMDD..csv" lrecl=1 recfm=n;
data _null_;
rc = fcopy("in", "out");
if rc ne 0 then
put "ERROR: for file &code._COVID19_TABLE&i._&YYYYMMDD..csv";
run;
filename in clear;
filename out clear;
/***************/
%end;
%mend;
%macro dummy_macro();
%if &nobs ne 4 %then %do;
filename mymail email from='test@test.dk' to=&mailto.
subject='ERROR -'
attach=("&logpath.&YYYYMMDD._log.log");
%end;
%else %do;
%prefix(1);
%prefix(2);
%prefix(3);
%prefix(4);
%prefix(5);
filename mymail email from='test@test.dk' to=&mailto.
subject='success';
ods listing file="&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();
Bart
It says
ERROR 23-2: Invalid option name member.
Sorry, should be:
filename out ZIP "&out_folder.\&code..zip" member = "&code._COVID19_TABLE&i._&YYYYMMDD..csv" lrecl=1 recfm=n;
B
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?
try this:
/* try this */
filename out ZIP "&out_folder.\&code..zip" member = "&code._COVID19_TABLE&i._&YYYYMMDD..csv" lrecl=1 recfm=n;
proc export data=tabel&i. replace
outfile=out
dbms=dlm
;
delimiter=';';
quit;
and drop my code between:
/* try this ****/
and
/***************/
If it fails, the try to replace data step from my code with:
data _null_;
rc = fcopy("in", "out");
if rc ne 0 then
put "ERROR: for file &code._COVID19_TABLE&i._&YYYYMMDD..csv";
else fdelete("in");
run;
All the best
Bart
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.