I need to start to process my program only if a file was uploaded in a directory.
I developed a code to verify if the file exist and it works well when the file are in the directory!
When the file doesn't exist I tryed to make the program wait a period of time then process the code again with the sleep function. However it isn't working. The program doesn't wait the specified time.
Sorry for my bad english. Can anyone help me?
SAS code:
%LET TESTFILE = "/usuario/teste/TB_SAIDA_GPC.TXT";
%MACRO FINDIT;
%DO %UNTIL(%SYSFUNC(FILEEXIST(&TESTFILE)));
PROC SQL;
CREATE TABLE WORK.TESTE AS
SELECT *
FROM WORK.TB_SAIDA_GPC;
QUIT;
SLEEP(60);
%END;
%MEND;
%FINDIT;
From SAS manual, it reads "The SLEEP function suspends the execution of a program that invokes this function for a period of time that you specify. The program can be a DATA step, macro, IML, SCL, or anything that can invoke a function. The maximum sleep period for the SLEEP function is 46 days."
So Sleep() can't be used by itself. Try below:
%LET TESTFILE = "/usuario/teste/TB_SAIDA_GPC.TXT";
%MACRO FINDIT;
%DO %UNTIL(%SYSFUNC(FILEEXIST(&TESTFILE)));
data _null_;
rc=SLEEP(60);
run;
%END;
PROC SQL;
CREATE TABLE WORK.TESTE AS
SELECT *
FROM WORK.TB_SAIDA_GPC;
QUIT;
%MEND;
%FINDIT;
Put the PROC SQL statement after the %end.
From SAS manual, it reads "The SLEEP function suspends the execution of a program that invokes this function for a period of time that you specify. The program can be a DATA step, macro, IML, SCL, or anything that can invoke a function. The maximum sleep period for the SLEEP function is 46 days."
So Sleep() can't be used by itself. Try below:
%LET TESTFILE = "/usuario/teste/TB_SAIDA_GPC.TXT";
%MACRO FINDIT;
%DO %UNTIL(%SYSFUNC(FILEEXIST(&TESTFILE)));
data _null_;
rc=SLEEP(60);
run;
%END;
PROC SQL;
CREATE TABLE WORK.TESTE AS
SELECT *
FROM WORK.TB_SAIDA_GPC;
QUIT;
%MEND;
%FINDIT;
You've got already all you need from others to make your current code work.
If available then I personally would go an approach using a scheduler where you trigger your process "on file arrival".
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.