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

Hello,

I am  Base SAS Student.

 

I'm trying to do a Combining Various Boolean Operators but I was get some error to execute this below code. First I had making New Database then I tried to combine data with using Boolean Logic.

 

I tried using this code but it didn’t work

 

As an example, the data set Medical contains information on clinic, diagnosis (DX), and weight. A program to list all patients who were seen at the HMC clinic and had either a diagnosis 7 or 9 or weighted over 180 pounds demonstrates how to combine various Boolean operators:


Data Learning_From_Medical;
      Length Id $ 3
                  VisitDate $ 10;
      Input Id Clinic $ DX Weight VisitDate;
Cards;
001 HMX 18 220 05/08/2006
003 TDX 8 265 02/06/2006
005 HTX 20 285 04/04/2006
004 HMC 9 185 25/07/2006
025 TFT 7 272 28/06/2006
032 HMX 12 160 18/02/2006
065 TDX 28 289 16/03/2006
072 HTX 32 255 12/09/2006
099 TFT 44 112 09/09/2006
050 HMC 88 198 12/12/2006
065 HTX 120 250 02/07/2006
002 HMC 7 162 20/11/2006
008 TDX 65 277 15/08/2006
012 HMC 12 222 14/04/2006
006 TFT 6 666 06/06/2006
;
RUN;

 

Title "Example of Boolan Expressions";
Proc print Data=learning_from_medical;
            where Clinic eq 'HMC' and
            (DX in ('7','9') or
             Weight gt 180);
id ID;
var Clinic DX Weight VisitDate;
Run;

 

22222222222.jpg

 

Can someone please give me the exact code to solve this error?

 

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

since DX is a numeric variable we need to use numeric values without the quotes

 

Proc print Data=learning_from_medical;
            where Clinic eq 'HMC' and
            (DX in (7,9) or
             Weight gt 180);
id ID;
var Clinic DX Weight VisitDate;
Run;
Thanks,
Jag

View solution in original post

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

since DX is a numeric variable we need to use numeric values without the quotes

 

Proc print Data=learning_from_medical;
            where Clinic eq 'HMC' and
            (DX in (7,9) or
             Weight gt 180);
id ID;
var Clinic DX Weight VisitDate;
Run;
Thanks,
Jag
Meet_SAS
Fluorite | Level 6

Thank you so much! I have the output this time.   Again, thank you for your time and your help.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 711 views
  • 2 likes
  • 2 in conversation