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. 

SAS Innovate 2025: Call for Content! Submit your proposals before Sept 16. Accepted presenters get amazing perks to attend the conference!

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. 

SAS Innovate 2025: Call for Content! Submit your proposals before Sept 16. Accepted presenters get amazing perks to attend the conference!
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: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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