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.
Hello,
in SAS VA,
IF ( 'ResolvedTeam'n In ('A') )
RETURN ' ProductResposibleTeam'n
ELSE 'ResolvedTeam'n
Let me know.
Thanks & Regards,
Teja Surapaneni
Hi,
Please try this:
data want;
set have;
NewColumn=ResolvedTeam;
if ResolvedTeam='A' then NewColumn=ProductResposibleTeam;
run;
Here is the error I am getting:
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;
The code works but the column is not created. Why?
Thanks again.
Hello,
in SAS VA,
IF ( 'ResolvedTeam'n In ('A') )
RETURN ' ProductResposibleTeam'n
ELSE 'ResolvedTeam'n
Let me know.
Thanks & Regards,
Teja Surapaneni
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.
Thank you so much.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.