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.
('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" ;
('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" ;
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?
the second clause replaces the first one.
is this home work?
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.