Hello All,
I would like to know if my traitement finish before 09:15 AM :
%let statut = OK;
data _null_;
call symput ('timenow',put (time(),hhmm.));
run;
%put &timenow;
--09:08
%macro tempsko;
%if '09:15't <= &timenow %then %do;
%let statut=KO;
%end;
%mend;
%tempsko;
%put &statut;
-- KO ???
Thx for your help
This code work :
%let statut = OK;
%put &statut;
data _null_;
call symput ('timenow', time());
run;
%macro tempsko;
%if %sysevalf('09:15't <= &timenow) %then %do;
%let statut=KO;
%end;
%mend;
%tempsko;
%put &statut;
Thx all for your help
Since timenow contains a string and not a number, a character comparison is used, and the single quote comes before any digit in the ASCII table. Make a time literal out of your timenow reference:
%let statut = OK;
data _null_;
call symput ('timenow',put (5000,hhmm.));
run;
%put &timenow;
options mprint mlogic symbolgen;
%macro tempsko;
%if '09:15't <= "&timenow"t %then %do;
%let statut=KO;
%end;
%mend;
%tempsko;
%put &statut;
Sorry, it does not work.
Une nouvelle formulation serait : Comment puis-je tester si mon traitement est passé avant 09:15 AM
Thx for tour time
%let statut = OK;
data _null_;
call symput ('timenow',put (time(),hhmm.));
run;
%put &timenow;
%macro tempsko;
data _null_;
if '09:15't le "&timenow"t then call symput('statut','KO');
run;
%mend;
%tempsko;
%put &statut;
Please let us know if this worked for you.
The implied %EVAL() function call of the %IF statement does not recognize date/time/datetime literals. Make an explicit call to %SYSEVALF() instead. Also you are comparing the string 09:80 to the time value '09:15't.
%if %sysevalf('09:15't <= "&timenow"t) %then %do;
Sorry, it does not work.
A new formulation would be:
How can I test if my treatment is passed before 09:15 AM
Thx for tour time
Show more details of what code you are using.
%let statut=OK;
%put &statut;
data _null_;
call symput ('timenow', time());
run;
%put &timenow;
%macro tempsko;
%if '14:40't <= &timenow %then %do;
%let statut=KO;
%end;
%mend;
%tempsko;
%put &statut;
DO NOT format macro variables.
%let statut = OK;
data _null_;
call symput ('timenow',time()); /* NOTE: unformatted */
run;
%macro tempsko;
%if '09:15't <= &timenow %then %do;
%let statut=KO;
%end;
%mend;
%tempsko
%put &=statut;
It does not work 😞
This code work :
%let statut = OK;
%put &statut;
data _null_;
call symput ('timenow', time());
run;
%macro tempsko;
%if %sysevalf('09:15't <= &timenow) %then %do;
%let statut=KO;
%end;
%mend;
%tempsko;
%put &statut;
Thx all for your help
@PaigeMiller %EVAL() does not treat time (or other) literals as special cases, it just treats them as text strings. You need to explicitly call %SYSEVALF() instead of letting SAS do an implicit call to %EVAL().
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.