ERROR: WHERE clause operator requires compatible variables.

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

ERROR: WHERE clause operator requires compatible variables.

Hi, need to get the info in a cell, put in a variable and try to filter an other dataset according that info. 

I've try two ways.. no success.

Frist one: 

Comment: into of the cell is in the location COL1,1.

Show the error. 

 

%let nombre=d_20500_Ward_6;
data x_new;
set s3;
a = put(COL1,1.); 

data &nombre;
set CLUSTER.&nombre(where=(NUMCLUSTER='&a.'));
run;

 

Second one:

Comment: Same error

 

%let nombre=d_20500_Ward_6;

PROC SQL ;
select * from s3 as a;
CREATE TABLE s4 as select * from cluster.&nombre where NUMCLUSTER="&a.";

 

Pd: I've been try with NUMCLUSTER=&a, &'a.', &a .. no success. 

 

Thanks


Accepted Solutions
Solution
‎10-25-2016 01:35 AM
Super User
Posts: 6,785

Re: ERROR: WHERE clause operator requires compatible variables.

Posted in reply to mariange8282

There are at least a couple of errors here. 

 

One error is corrected part-way through.  When you refer to a macro variable such as &a, you cannot use single quotes around it.  SIngle quotes prevent the resolution of the variable.  Double quotes are fine.

 

Second, there is no macro variable &a.  If you wanted to create one based on COL1, you would need this sort of statement in your DATA step:

 

call symputx('a', put(COL1, 1.);

 

If you want SQL to create &a, the syntax is again different:

 

select put(col1, 1.) into : a from s3;

 

In that case, the data set S3 better have a single observation in it for this to generate the proper result. 

View solution in original post


All Replies
Solution
‎10-25-2016 01:35 AM
Super User
Posts: 6,785

Re: ERROR: WHERE clause operator requires compatible variables.

Posted in reply to mariange8282

There are at least a couple of errors here. 

 

One error is corrected part-way through.  When you refer to a macro variable such as &a, you cannot use single quotes around it.  SIngle quotes prevent the resolution of the variable.  Double quotes are fine.

 

Second, there is no macro variable &a.  If you wanted to create one based on COL1, you would need this sort of statement in your DATA step:

 

call symputx('a', put(COL1, 1.);

 

If you want SQL to create &a, the syntax is again different:

 

select put(col1, 1.) into : a from s3;

 

In that case, the data set S3 better have a single observation in it for this to generate the proper result. 

Contributor
Posts: 23

Re: ERROR: WHERE clause operator requires compatible variables.

Posted in reply to Astounding
Thank you so much!
With the data step, didn't work.. my final table was empty.. However, PROC SQL works perfect.
Super User
Posts: 6,785

Re: ERROR: WHERE clause operator requires compatible variables.

Posted in reply to mariange8282

In the DATA step, did you remember to switch from single quotes to double quotes?

Contributor
Posts: 23

Re: ERROR: WHERE clause operator requires compatible variables.

[ Edited ]
Posted in reply to Astounding

I with double coutle appear the same error, however just &a is enough. Thanks

 

Sol: 

 

%let nombre=d_20500_Ward_6;
data x_new;
set s3;
call symputx('a', put(COL1, 1.);

 

data &nombre;
set CLUSTER.&nombre(where=(NUMCLUSTER=&a));
run;

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 1824 views
  • 0 likes
  • 2 in conversation