Hi there, getting the below error:
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
0 < &countjobs.
ERROR: Skipping to next %END statement.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
0 >= &countjobs.
ERROR: Skipping to next %END statement.
The file "C:/Jobs.xlsx" contains a value '3' which is identified as numeric. I think the error has to do with the &countjobs variable. When I use a normal digit for example a 3 then it works.
I am comparing the value in the file verse the count of files in the directory in the if conditions.
%include "C:/list.sas"; %let path_in= C:/FileCheck; %lfiles("C:/File",txt) %let filecount = 0; %if %sysfunc(exist(tables)) %then %do; proc sql; create table filecount as select count(name) into: filecount from tables; quit; %end; proc import out=Jobcount replace datafile = "C:/Jobs.xlsx" dbms = xlsx; getnames=yes; run; proc sql; create table countjobs as select Countjobs into: countjobs from Jobcount; quit; %if &filecount. < &countjobs. %then %do; put("less than"); %end; %if &filecount. >= &countjobs. %then %do; put("ge"); %end;
That's why Maxim 2 is Read the Log.
(translate that to "always read the complete log from top down")
Seen this?
WARNING: INTO clause is ignored in the CREATE TABLE statement.
this alerts you to the fact that INTO is not working here, so the macro variable is not created.
When creating macro variables with SQL, only use a SELECT:
proc sql noprint;
select countjobs into: countjobs
from jobcount;
quit;
Also use the NOPRINT option to prevent creating print output.
Please post the complete log of these steps:
proc import out=Jobcount replace
datafile = "C:/Jobs.xlsx"
dbms = xlsx;
getnames=yes;
run;
proc sql;
create table countjobs as
select Countjobs into: countjobs
from Jobcount;
quit;
That's why Maxim 2 is Read the Log.
(translate that to "always read the complete log from top down")
Seen this?
WARNING: INTO clause is ignored in the CREATE TABLE statement.
this alerts you to the fact that INTO is not working here, so the macro variable is not created.
When creating macro variables with SQL, only use a SELECT:
proc sql noprint;
select countjobs into: countjobs
from jobcount;
quit;
Also use the NOPRINT option to prevent creating print output.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.