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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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