Hi everybody,
my need is to execute a proc export all the days in the programme, but i want to obtain the output file only if the day of the week is tuesday. Could you please help me?
I wrote a datastep like this but it doesn't work. Why?
data _null_;
if WEEKDAY(today())=3 then do;
PROC EXPORT DATA= RLWORK.prova
OUTFILE= "DIRECTORY"
DBMS=DLM REPLACE LABEL;
DELIMITER='3B'x;
PUTNAMES=YES;
RUN;
run;
afaik, you cannot have a proc export within a datastep. try macro programming instead.
%macro _xprt;
%if sysfunc(WEEKDAY(today())) = 3 %then %do;
PROC EXPORT DATA= RLWORK.prova
OUTFILE= "DIRECTORY"
DBMS=DLM REPLACE LABEL;
DELIMITER='3B'x;
PUTNAMES=YES;
RUN;
%end;
%mend _xprt;
%_xprt;
afaik, you cannot have a proc export within a datastep. try macro programming instead.
%macro _xprt;
%if sysfunc(WEEKDAY(today())) = 3 %then %do;
PROC EXPORT DATA= RLWORK.prova
OUTFILE= "DIRECTORY"
DBMS=DLM REPLACE LABEL;
DELIMITER='3B'x;
PUTNAMES=YES;
RUN;
%end;
%mend _xprt;
%_xprt;
Here's an example of @LinusH call execute suggestion:
data _null_; if WEEKDAY(today())=3 then do; Call execute ('PROC EXPORT DATA= RLWORK.prova OUTFILE= "DIRECTORY" DBMS=DLM REPLACE LABEL; DELIMITER="3B"x; PUTNAMES=YES; RUN;'); end; run;
Assumes of course that your outfile is substituted with something that will work. Not sure why you are using the hex "3B"x instead of
";" though.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.