DATA Step, Macro, Functions and more

SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 82
Accepted Solution

SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

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,



Accepted Solutions
Solution
‎09-03-2014 12:32 PM
Trusted Advisor
Posts: 3,215

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

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


All Replies
Super User
Posts: 19,861

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

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.

Frequent Contributor
Posts: 82

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

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

Super Contributor
Posts: 307

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

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.

Valued Guide
Posts: 2,177

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

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

SAS Super FREQ
Posts: 8,868

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

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

Frequent Contributor
Posts: 82

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

Posted in reply to Cynthia_sas

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

SAS Super FREQ
Posts: 8,868

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

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

Frequent Contributor
Posts: 82

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

Posted in reply to Cynthia_sas

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

Solution
‎09-03-2014 12:32 PM
Trusted Advisor
Posts: 3,215

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

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 --<-----
Frequent Contributor
Posts: 82

Re: SAS 9.4 ERROR: WHERE clause operator requires compatible variables.

Hi Jaap,

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

Thanks,

Xinjian

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 18113 views
  • 0 likes
  • 6 in conversation