DATA Step, Macro, Functions and more

IF Statement with many AND

Posts: 60

IF Statement with many AND

Hi All,


tried to do IF with many AND condition in dataset, but results was different. Appreciated if anyone can explain further. My code as per below:-


IF ID = 'XXX' AND NPL_Code = 'Y' AND Location_Code = '123456' AND 'O/S> 0'n = 'YES' THEN 

Super User
Posts: 9,855

Re: IF Statement with many AND

Please supply example data that illustrates where your condition did not perform as expected. Use a data step for posting your example data.

Not that avoiding all-uppercase coding and using the code-posting subwindow ("little running man" icon) improves readabilty of your code:

if ID = 'XXX' and NPL_Code = 'Y' and Location_Code = '123456' and 'O/S> 0'n = 'YES' then 
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Posts: 60

Re: IF Statement with many AND

Posted in reply to KurtBremser
Hi KurtBremser,

Apologize for late reply. I'm have detected the root cause and fix it by myself.

Anyway thank you for your response and time.
Ask a Question
Discussion stats
  • 2 replies
  • 1 like
  • 2 in conversation