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

Hi, I had a SAS 9.4 installed about 2 months. I have running a same program about several days. suddenly, it appeared an error today in log file as

ERROR: WHERE clause operator requires compatible variables.

Does someone know how fix this problem?

Thanks,


1 ACCEPTED SOLUTION

Accepted Solutions
jakarman
Barite | Level 11

You are using a proc import. That one is delivering results on the content and they are not predefined.

All depends ...
It could be LA was first numeric so you where statement has compatible variables.

This time someone send it and LA is now defined by him as character. This will cause the mentioned error.

By that your unexpected behavior is an expected result of the design of the data processing. No problem...

---->-- ja karman --<-----

View solution in original post

10 REPLIES 10
Reeza
Super User

It means your where condition is expecting a numeric or character variable and you're providing the opposite. If you have an import step in your program I'd start there for debugging, using the variables indicated in the WHERE clause as an indicator of what to check.

xinjian
Calcite | Level 5

I use proc contents to check, the WHERE clause variable is a character variable.

Fugue
Quartz | Level 8

To add to Reeza's comment, try a PROC CONTENTS on your data set to see if the variables are of the type you expect.

Peter_C
Rhodochrosite | Level 12

Sounds like you have a error occuring when the progran hasn't changed.

that kind of thing happens with the "flexibility" of proc import reading from excel

Cynthia_sas
SAS Super FREQ

But another possibility is that former versions of a variable used to be numeric or character in the Excel file and, possibly, the input data changed the format of the variable, so now the WHERE statement that used to work doesn't work. It really comes down to either the data or the code. I have seen PROC IMPORT act funky -- but usually it's my fault for changing some option or registry setting (like the one for guessingrows) without remembering that I did the change.

cynthia

xinjian
Calcite | Level 5

Hi Cynthia,

Here is the program:

PROC IMPORT OUT=WORK.BASELINE

DATAFILE="d:\Baseline combine.xlsx"

  DBMS=EXCEL REPLACE;

SHEET="Sheet9$";

GETNAMES=YES;

  MIXED=NO;

SCANTEXT=YES;

USEDATE=YES

SCANTIME=YES;

RUN;

Do I need to change the program to solve the problem? I think the problem is from excel file. When I sort data within excel, the number of one character variable ( ID variable)automatically changed(only one observation). I have to undo the sort function to change back. Should I save excel file as a special format?

Thanks,

Xinjian

Cynthia_sas
SAS Super FREQ

Hi:

  This is impossible to answer in the Forum. I would recommend that you open a track with Tech Support. There is no WHERE clause in your code. So either you are not showing all your code or PROC IMPORT is giving you a WHERE statement error, which doesn't make sense. But since you did NOT post your log showing PROC IMPORT giving you the WHERE statement error, there is no basis on which to make even an educated guess.

  You maintain that the program has not changed. However, SOMETHING changed. Either the data changed or the program changed. You indicate that your version of SAS changed, but did not say whether you had run the program previously in the last 2 months or not. This is a case where someone has to look at ALL your code (ALL your code) and your log for ALL your code and look at ALL your data in order to help you come to a resolution.

cynthia

xinjian
Calcite | Level 5

Hi, thanks for your response. I run same program last week with SAS 9.4 without problem. It happened 2 days ago. Here is the log file:

404  title 'normality test for ICA WITH ACA NORMAL ';

405  proc univariate data = baseline2 normal plot;

406  where LA=1 ;

ERROR: WHERE clause operator requires compatible variables.

407  var LICAM;

408  id number;

409  run;

LA is a character variable.

Thanks

Xinjian

jakarman
Barite | Level 11

You are using a proc import. That one is delivering results on the content and they are not predefined.

All depends ...
It could be LA was first numeric so you where statement has compatible variables.

This time someone send it and LA is now defined by him as character. This will cause the mentioned error.

By that your unexpected behavior is an expected result of the design of the data processing. No problem...

---->-- ja karman --<-----
xinjian
Calcite | Level 5

Hi Jaap,

You are right. I changed LA to numeric. It works well.

Thanks,

Xinjian

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 10 replies
  • 76487 views
  • 0 likes
  • 6 in conversation