IF conditions in SQL

Reply
N/A
Posts: 0

IF conditions in SQL

This is Microsoft SQL Server Query, can SAS SQL can do something like this?
USE AdventureWorks;
GO
SELECT ProductNumber, Name, 'Price Range' =
CASE
WHEN ListPrice = 0 THEN 'Mfg item - not for resale'
WHEN ListPrice < 50 THEN 'Under $50'
WHEN ListPrice >= 50 and ListPrice < 250 THEN 'Under $250'
WHEN ListPrice >= 250 and ListPrice < 1000 THEN 'Under $1000'
ELSE 'Over $1000'
END
FROM Production.Product
ORDER BY ProductNumber ;
GO
SAS Super FREQ
Posts: 8,643

Re: IF conditions in SQL

Hi:
I believe the CASE clause is ANSI standard SQL. PROC SQL (the SAS implementation of SQL) does support use of the CASE clause. For more help on SAS and PROC SQL and the CASE clause, you might look in the PROC SQL documentation or consult with Tech Support for more help.

cynthia
Post a Question
Discussion Stats
  • 1 reply
  • 229 views
  • 0 likes
  • 2 in conversation