Hi,
I want to compare current time with '4:55't as below but my code is not working.
Can you please help to fix?
Thanks,
HHC
%MACRO _BREAK() ;
%let current_time = time(); /* Get the current time */
%IF ¤t_time < '4:55't %then %do;
%put "print before ";
%END;
%ELSE %do;
%put "print after";
%END;
%Mend;
%_BREAK();
Greetings,
I made the following modifications to your code:
%let current_time = time(); /* Get the current time */
Here, you assign the text time() to the macro variable (not the result of the function!). If you want to execute a data step function in macro code, you need to use %SYSFUNC:
%let current_time = %sysfunc(time());
It's a lot easier not using macro logic - not sure why you need a macro at all:
%MACRO _BREAK() ;
data _null_;
if time() < '4:55't then putlog "print before ";
else putlog "print after";
run;
%Mend;
%_BREAK();
Greetings,
I made the following modifications to your code:
Thank you so much for helping!
HHC
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.