BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ManitobaMoose
Quartz | Level 8

Hi,

 

I am not sure why this would not work. Any suggestions? Thanks.

 

Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;  
Libname myformat'/folders/myfolders/sasuser.v94' ; 
Options fmtsearch=(myformat) ;

Proc Print data=learn.sales noobs ; 
	where Region eq ('North' AND Quantity lt 160) 
	OR Customer eq "Pet's are Us" ; /* Double "" because Pet's*/
run ; 

 I am getting the following error:

 69         Proc Print data=learn.sales noobs ;
 70         where Region eq ('North' AND Quantity lt 160)
 71         OR Customer eq "Pet's are Us" ; /* Double "" because Pet's*/
 ERROR: WHERE clause operator requires compatible variables.
 72         run ;

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20
('North' AND Quantity lt 160) 

is a test. It returns a boolean value (0 or 1).

 

Then you test region eq 1, which triggers the message as the values are of different type.

 

Your test is malformed. You probably mean

 

	where (Region eq 'North' AND Quantity lt 160) 
	   OR Customer eq "Pet's are Us" ; 

 

 

 

View solution in original post

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20
('North' AND Quantity lt 160) 

is a test. It returns a boolean value (0 or 1).

 

Then you test region eq 1, which triggers the message as the values are of different type.

 

Your test is malformed. You probably mean

 

	where (Region eq 'North' AND Quantity lt 160) 
	   OR Customer eq "Pet's are Us" ; 

 

 

 

ManitobaMoose
Quartz | Level 8

Great, Thanks.

 

What about if I write the code:

Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;  
Libname myformat'/folders/myfolders/sasuser.v94' ; 
Options fmtsearch=(myformat) ;

Proc Print data=learn.sales noobs ; 
	where (Region eq 'North' AND Quantity lt 160) ; 
	where Customer eq "Pet's are Us" ; /* Double "" because Pet's*/
run ; 

This seems to only produce results for the second where clause (Pets are Us). Why is that?
ChrisNZ
Tourmaline | Level 20

the second clause replaces the first one.

is this home work?

ManitobaMoose
Quartz | Level 8

Hi, I'm teaching myself SAS from Learning SAS by Example. It has answers to only the odd problems. Plus, it helps to learn the concept by going on here when I am truly unclear about something.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 2842 views
  • 0 likes
  • 2 in conversation