if/then/else

Reply
Occasional Contributor
Posts: 9

if/then/else

i am having trouble with an if/then/else statement in the computed columns /advanced expression section of the query builder.. is there a super smarty out there that can help???


Super User
Posts: 17,868

Re: if/then/else

There's many, but you need to post your question with more details Smiley Happy

Occasional Contributor
Posts: 9

Re: if/then/else

ok, it's a situation where i have 2 values for an identifier from one of my data tables, ex t1Infotable_colors

i want my statement to be something like this:

if t1infotable_colors (in a list) pink or blue then i want it to display "pretty" else "ugly"  (the actual words as output in the computed column?

obviously the table and values are not my actual values/etc but this is for informational purposes only i am familiar with how to write in crystal syntax, i am new to SAS/SQL how to write this expression to get the desired output for my computed column Smiley Happy

because it is a "computed column" does it have to be a calculation?

i am trying to find the equivalent of a formula editor for creating my own formula field on my report.

Smiley Happy

Super User
Posts: 17,868

Re: if/then/else

You can also use the recode function in computed column rather than advanced expression to do this.

38261 - Using conditional logic in the SAS® Enterprise Guide 4.2 Query Builder

32160 - How to Apply IF-THEN-ELSE Logic by Using SAS® Enterprise Guide

Occasional Contributor
Posts: 9

Re: if/then/else

i appreciate the help!!

Super Contributor
Posts: 578

Re: if/then/else

I believe the query builder uses proc sql so you would need to use a case statement instead of an if/then..

case when t1infotable_colors in ('pink','blue') then 'pretty' else 'ugly' end

Occasional Contributor
Posts: 9

Re: if/then/else

thank you!

Super Contributor
Posts: 418

Re: if/then/else

I think the most important question to be asked here is why is Red not included in your list of pretty colors?

Hrmmm?

Haha sorry I couldn't resist

Ask a Question
Discussion stats
  • 7 replies
  • 311 views
  • 5 likes
  • 4 in conversation