SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

SQL Case-function problem: best way to leave one value alone?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

SQL Case-function problem: best way to leave one value alone?

I have a question about this code:

case VARNAME

when "Oil and Penguins" then "Oil and Penguins"

else propcase(VARNAME) end

It puts all the values in the VARNAME column into proper case, but makes an exception for "Oil and Penguins" because it shouldn't become "Oil And Penguins". It works correctly, but I strongly suspect that the second line is a bit clumsy. Is there a better way to tell it to leave "Oil and Penguins" alone? Something along the lines of "when 'Oil and Penguins' then nothing"?


Accepted Solutions
Solution
‎11-28-2012 03:30 PM
Respected Advisor
Posts: 4,644

Re: SQL Case-function problem: best way to leave one value alone?

I guess

case VARNAME

when "Oil and Penguins" then VARNAME

else propcase(VARNAME) end

would be a tad neater.

PG

PG

View solution in original post


All Replies
Solution
‎11-28-2012 03:30 PM
Respected Advisor
Posts: 4,644

Re: SQL Case-function problem: best way to leave one value alone?

I guess

case VARNAME

when "Oil and Penguins" then VARNAME

else propcase(VARNAME) end

would be a tad neater.

PG

PG
Frequent Contributor
Posts: 89

Re: SQL Case-function problem: best way to leave one value alone?

Can't believe I overlooked doing that. :smileyshocked:

Thanks!

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 250 views
  • 0 likes
  • 2 in conversation