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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

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;
Citrine10
Obsidian | Level 7
34 proc sql;
35 create table countjobs as
36 select Countjobs into: countjobs
37 from Jobcount;
WARNING: INTO clause is ignored in the CREATE TABLE statement.
NOTE: Compression was disabled for data set WORK.COUNTJOBS because compression overhead would increase the size of the data set.
NOTE: Table WORK.COUNTJOBS created, with 1 rows and 1 columns.

38 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Kurt_Bremser
Super User

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: 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
  • 3 replies
  • 1591 views
  • 0 likes
  • 2 in conversation