%SYSFUNC(INTCK("Second",&t1,&t2) generates error but INTCK in a data step works fine.
%let t1=%SYSFUNC(DateTime());
%let t2=%SYSFUNC(DateTime());
%let t=%SYSFUNC(INTCK("Second",&t1,&t2));
WARNING: An argument to the function INTCK referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set
to a missing value.
%put &=t1 &=t2 &=t;
LOG:
/*T1=1963997617.86803 T2=1963999438.99399 T=.*/
data a;
t=INTCK("Second",&t1,&t2);
run;
/* dataset a */
/*t */
/*1821 */
When using %sysfunc, which is a SAS macro construct, you don't enclose literal arguments to functions in quotes.
%let t1=%SYSFUNC(DateTime());
%let t2=%SYSFUNC(DateTime());
%let t=%SYSFUNC(INTCK(Second,&t1,&t2));
Confusing...perhaps. But it's just how SAS macro works as a text generator.
When using %sysfunc, which is a SAS macro construct, you don't enclose literal arguments to functions in quotes.
%let t1=%SYSFUNC(DateTime());
%let t2=%SYSFUNC(DateTime());
%let t=%SYSFUNC(INTCK(Second,&t1,&t2));
Confusing...perhaps. But it's just how SAS macro works as a text generator.
WARNING: An argument to the function INTCK referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range.
NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set
to a missing value.
If this WARNING/NOTE message said "drop apostrophes in the first argument" or "error in the first argument", it will be much more useful that this lengthy text.
Not sure how %SYSFUNC() is supposed to read your mind. I think it is pretty much just echoing the same error as would be generated if you passed an invalid value in a data step.
10 %put %sysfunc(intck('month',1,2)); WARNING: An argument to the function INTCK referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range. NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set to a missing value. . 11 %put %sysfunc(intck(fred,1,2)); WARNING: An argument to the function INTCK referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range. NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set to a missing value. . 12 13 data _null_; 14 x=intck("'month'",1,2); 15 x=intck("fred",1,2); 16 run; NOTE: Invalid argument to function INTCK('''month''',1,2) at line 14 column 5. NOTE: Invalid argument to function INTCK('fred',1,2) at line 15 column 5. x=. _ERROR_=1 _N_=1 NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to missing values. Each place is given by: (Number of times) at (Line):(Column). 1 at 14:5 1 at 15:5 NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
I do not think that is too difficult to identify what argument contains an issue.
Datetime values are numbers of seconds. So why bother with INTCK() to get the difference in seconds you can just subtract the values.
%let duration=%sysevalf(&t2-&t1);
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.