Desktop productivity for business analysts and programmers

Where statement with two conditions

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Where statement with two conditions

Please help.

I'm very new to SAS and trying to modify and existing proc. 

Right now the code looks like this. I want to add a second condition the where statement so that it's picking up where transtypedesc does not equal either 'change account' or 'void account'.  So I want to exclude change and void statuses.  I've tried a handful of attempts to add a second condition to the where statement and keep getting errors.

 

inner join acct.State as d on c.LobGuid = d.LobGuid

inner join acct.loc as e on d.StateGuid = e.StateGuid

inner join acct.locItemInfo as f on e.LocGuid = f.LocGuid

where BusinessUnitCd = 'AA'

and TransTypeDesc <> 'CHANGE ACCOUNT');

quit;


Accepted Solutions
Solution
‎10-20-2011 04:32 PM
Esteemed Advisor
Posts: 7,295

Where statement with two conditions

Try:

  where BusinessUnitCd = 'AA'

   and not upcase(TransTypeDesc) in ("CHANGE ACCOUNT","VOID ACCOUNT")

;

Your current statement ended with a parenthesis, but you didn't show all of your code, thus don't know if an additional parenthesis is needed.

View solution in original post


All Replies
Solution
‎10-20-2011 04:32 PM
Esteemed Advisor
Posts: 7,295

Where statement with two conditions

Try:

  where BusinessUnitCd = 'AA'

   and not upcase(TransTypeDesc) in ("CHANGE ACCOUNT","VOID ACCOUNT")

;

Your current statement ended with a parenthesis, but you didn't show all of your code, thus don't know if an additional parenthesis is needed.

New Contributor
Posts: 2

Where statement with two conditions

Nice one sir.  You were correct.  There were two places where the end paren was not added when the original programmer added the 2nd condition.  I was so busy looking at the syntax and trying to work around that and I didn't notice the issue.  Unfortunately SAS EG didn't throw an error on the missing paren, like it would in VBA, it just got hung-up. 

Esteemed Advisor
Posts: 7,295

Where statement with two conditions

That is twice today that people have called me "Sir".  I REALLY prefer "Art" these days.  But, glad to see that you have identified the problem.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 130 views
  • 0 likes
  • 2 in conversation