Help using Base SAS procedures

problem of using %eval

Reply
Regular Contributor
Posts: 222

problem of using %eval


Hello everyone,

I will get an error if I run the SAS code below.

Please give me some advise.

Thanks

Mike

%let time1=%sysfunc(time());
%put &time1;

    data _null_;

      wait=sleep(5);

    run;

%let time2=%sysfunc(time());
%put &time2;
%let diff=%eval(&time2-&time1);

*ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required;

Respected Advisor
Posts: 3,777

Re: problem of using %eval

Use SYSEVALF or use a FORMAT with SYSFUNC (second argument) that returns the number of seconds as an integer.

Super User
Posts: 5,085

Re: problem of using %eval

On a related note, if you do switch to %SYSEVALF, understand that the resulting &DIFF will contain a decimal point.  That has the potential to cause problems down the road if &DIFF is used in later %EVAL functions.

Ask a Question
Discussion stats
  • 2 replies
  • 175 views
  • 6 likes
  • 3 in conversation