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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.