BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

Hello,

I would like to get the counts for any variables equal to 1; I use Proc Freq table below.  Why SAS showed an error message?  Thank you.

proc freq data=H4_SEC_UC;
	table sec_noumedcond sec_uasthma;
	 where (sec_noumedcond=1 or sec_uasthma=1);
run;
211  proc freq data=H4_SEC_UC;
212      table sec_noumedcond    sec_uasthma ;
219       where (sec_noumedcond=1 or sec_uasthma=1);
ERROR: WHERE clause operator requires compatible variables.
226  run;

NOTE: The SAS System stopped processing this step because of errors.
1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

The error message suggests that at least one of the variables on your WHERE statement are character rather than numeric.  So you would need to code perhaps:

where (sec_noumedcond='1' or sec_uasthma='1');

'Compatible' in the error message means being the correct type.  The WHERE statement doesn't do automatic numeric to character conversions.  If you don't know which variable is character, you can run PROC CONTENTS on the dataset.

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

View solution in original post

1 REPLY 1
Quentin
Super User

The error message suggests that at least one of the variables on your WHERE statement are character rather than numeric.  So you would need to code perhaps:

where (sec_noumedcond='1' or sec_uasthma='1');

'Compatible' in the error message means being the correct type.  The WHERE statement doesn't do automatic numeric to character conversions.  If you don't know which variable is character, you can run PROC CONTENTS on the dataset.

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 274 views
  • 1 like
  • 2 in conversation