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.
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.
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.