I am trying to write a macro that checks a table every 60 seconds to see if there is an entry for today's date. If not, it sleeps 60 seconds, if found, it starts a process. I think I have two problems: not sure if I am using Call Symput correctly, and the &sysdate is character, and I am trying to compare to a date (numberic) value. Any help would be greatly appreciated!
%LET WAIT = 'TRUE';
%DO %WHILE (&WAIT = 'TRUE');
IF DATE = "&SYSDATE" THEN CALL SYMPUT('WAIT', 'FALSE');
There is no %SLEEP macro, unless you have defined it, possibly to use a DATA step with SLEEP function? You may want to explore the use of %SYSFUNC and invoking a CALL function in that manner without a DATA step.
Also the &SYSDATE value (in double-quotes) must be identified as a SAS DATE constant by adding the "D" suffix to the quoted string.
If appropriate, the %SLEEP macro can be eliminated by using:
%LET X = %SYSFUNC(SLEEP(60));
Also, if you only need to detect the presence of at least one obs for the current date, consider using a WHERE and also have a DO/END loop to invoke the SYMPUT, along with a STOP; statement -- given what you have shown for a DATA step invocation, there is really no need to pass the entire file, right? Just a thought for SAS programming optimization.
If you intend to do it macro-based, you will need to work with %SYSFUNC and look at the DATE-related functions (normally used in a DATA step but accessible in macro language when using SYSFUNC. Then construct a new macro variable, again using SYSFUNC, and the MDY function.
Suggest in the future you consider creating a new post for a new question or discussion topic.
Also, you should consider working with the lock table features.
If any process tries to write something, while you checking (reading) the table, or you try to check the table while its being written to, you'll get an error (unless it's a SAS/SHARE library or, your SO is able to do the lock handling, like z/OS).