DATA Step, Macro, Functions and more

wrong variable type: how to search

Accepted Solution Solved
Reply
Super Contributor
Posts: 318
Accepted Solution

wrong variable type: how to search

In my data, some character variables were defined as numeric by mistake. 

In this case, if I want to search "Yes" or "No", it does not work. 

 

25 GOPTIONS ACCESSIBLE;
26 data test;
27 set db.ct_reading;
28 where qc_accepted = 'Yes';
ERROR: WHERE clause operator requires compatible variables.
29 run;

 

Capture.PNG

 

How to work around this situation? 

I also see some cases where character variable missing is "." and numeric variable missing is " ". 

How to condition on these mis-typed missing values?


Accepted Solutions
Solution
‎10-13-2017 03:06 PM
Trusted Advisor
Posts: 1,932

Re: wrong variable type: how to search

Posted in reply to fengyuwuzu

These numeric variables are formatted to show "yes" or "no"

 

You have to search for the numeric values, such as (this is often the case, but not always) 1 for yes and 0 for no. 

 

Or you could remove the format, and then you can see in the view which values they have.

View solution in original post


All Replies
Solution
‎10-13-2017 03:06 PM
Trusted Advisor
Posts: 1,932

Re: wrong variable type: how to search

Posted in reply to fengyuwuzu

These numeric variables are formatted to show "yes" or "no"

 

You have to search for the numeric values, such as (this is often the case, but not always) 1 for yes and 0 for no. 

 

Or you could remove the format, and then you can see in the view which values they have.

Super Contributor
Posts: 318

Re: wrong variable type: how to search

Posted in reply to PaigeMiller

yes, I used 1 for yes and it works. 

 

I will also try removing format. 

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 100 views
  • 0 likes
  • 2 in conversation