BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SPR
Quartz | Level 8 SPR
Quartz | Level 8

%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        */

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

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. 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

View solution in original post

5 REPLIES 5
ChrisHemedinger
Community Manager

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. 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
SPR
Quartz | Level 8 SPR
Quartz | Level 8

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.

Tom
Super User Tom
Super User

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
SPR
Quartz | Level 8 SPR
Quartz | Level 8

I do not think that is too difficult to identify what argument contains an issue.

Tom
Super User Tom
Super User

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);

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1738 views
  • 2 likes
  • 3 in conversation