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,
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...
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.
I use proc contents to check, the WHERE clause variable is a character variable.
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.
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
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
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
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
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
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...
Hi Jaap,
You are right. I changed LA to numeric. It works well.
Thanks,
Xinjian
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.