I want to filter the data based on a where statement. The code is quite simple.
data sample;
set total;
where var = 1;
run;
However, I got the wrong message
ERROR: WHERE clause operator requires compatible variables.
I check var is numeric variable
Please help me figure out this issue. Thanks
@SeaMoon_168 wrote:
I want to filter the data based on a where statement. The code is quite simple.
data sample; set total; where var = 1; run;
However, I got the wrong message
ERROR: WHERE clause operator requires compatible variables.
I check var is numeric variable
Please help me figure out this issue. Thanks
I doubt that SAS is wrong here.
Make sure you checked the right TOTAL dataset. Single level names normally mean WORK datasets. But if you defined a USER libref or used the USER system option to select some other libref to use for one character names then SAS might. Because of the error with the WHERE statement the SAS log will not help you since it will not show what actual dataset it attempted to read from.
Also check if TOTAL is a VIEW instead of a dataset. In that case it might be using a WHERE statement (or WHERE= dataset option) that references some other variable and that is the source of the error. Although that would normally provide more information.
59 data want ; 60 set class_v; ERROR: Variable var has been defined as both character and numeric. ERROR: WHERE clause operator requires compatible variables. ERROR: Failure loading view WORK.CLASS_V.VIEW. Error detected during View Load request. 61 where name='Alfred'; 62 run;
Have you tried:
where var='1';
Can you send a PROC CONTENTS of the Total data set?
proc contents data=total;
run;
@SeaMoon_168 wrote:
I want to filter the data based on a where statement. The code is quite simple.
data sample; set total; where var = 1; run;
However, I got the wrong message
ERROR: WHERE clause operator requires compatible variables.
I check var is numeric variable
Please help me figure out this issue. Thanks
I doubt that SAS is wrong here.
Make sure you checked the right TOTAL dataset. Single level names normally mean WORK datasets. But if you defined a USER libref or used the USER system option to select some other libref to use for one character names then SAS might. Because of the error with the WHERE statement the SAS log will not help you since it will not show what actual dataset it attempted to read from.
Also check if TOTAL is a VIEW instead of a dataset. In that case it might be using a WHERE statement (or WHERE= dataset option) that references some other variable and that is the source of the error. Although that would normally provide more information.
59 data want ; 60 set class_v; ERROR: Variable var has been defined as both character and numeric. ERROR: WHERE clause operator requires compatible variables. ERROR: Failure loading view WORK.CLASS_V.VIEW. Error detected during View Load request. 61 where name='Alfred'; 62 run;
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.
Ready to level-up your skills? Choose your own adventure.