BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tassekurt
Fluorite | Level 6

Hi, I am very new to SAS Visual Analytics and I am having problems creating a new Column where I have to use an If Then Else Statement.

The context is: I created a query in design mode with multiple tables. I noticed that we cannot use the Conditional statement in expression clause. How can I create a column with IF Then Else?

 

These Two Columns exist already

ResolvedTeam         ProductResposibleTeam

A                                              X

A                                              Z

B                                              P                     

C                                              O        

A                                              O

C                                              P         

D                                              W

What I need is: A new column where I combine two fields under the condition: if resolved by A then return the RroductResponsibleTeam if not return the ResolvedTeam.

What I need as an output is:

NewColumn

X

Z

B

C

O

C

D

 

Please help with as much details as possible as I am new to the tool. Thanks in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions
TejaSurapaneni
Lapis Lazuli | Level 10

Hello,

 

in SAS VA,

 

IF ( 'ResolvedTeam'n In ('A') )
RETURN ' ProductResposibleTeam'n
ELSE 'ResolvedTeam'n

 

 

Let me know.

 

 

Thanks & Regards,

Teja Surapaneni

View solution in original post

8 REPLIES 8
stat_sas
Ammonite | Level 13

Hi,

 

Please try this:

 

data want;
set have;
NewColumn=ResolvedTeam;
if ResolvedTeam='A' then NewColumn=ProductResposibleTeam;
run;

tassekurt
Fluorite | Level 6

Here is the error I am getting:

SAS error.png

stat_sas
Ammonite | Level 13

Data set "have" would be based on information provided. I've added syntax to create data set. Please try this:

 

data have;
input ResolvedTeam $ ProductResposibleTeam $;
datalines;
A  X
A  Z
B  P
C  O
A  O
C  P
D  W
;

 

data want;
set have;
NewColumn=ResolvedTeam;
if ResolvedTeam='A' then NewColumn=ProductResposibleTeam;
run;

tassekurt
Fluorite | Level 6

The code works but the column is not created. Why?

Thanks again.

 

LinusH
Tourmaline | Level 20
Another option is to create the column in the Visual Data Builder. There you use SQL syntax, which means that you can use CASE-WHEN-THEN-ELSE-syntax.
Data never sleeps
TejaSurapaneni
Lapis Lazuli | Level 10

Hello,

 

in SAS VA,

 

IF ( 'ResolvedTeam'n In ('A') )
RETURN ' ProductResposibleTeam'n
ELSE 'ResolvedTeam'n

 

 

Let me know.

 

 

Thanks & Regards,

Teja Surapaneni

tassekurt
Fluorite | Level 6

I really don’t know how it works. There is no error but nothing is happening as an output. Is there anything to do with libraries?

 

Thanks again.

 

tassekurt
Fluorite | Level 6

Thank you so much.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 19919 views
  • 6 likes
  • 4 in conversation