BookmarkSubscribeRSS Feed
TurnTheBacon
Fluorite | Level 6

I'm working in an SQL Join transformation in DI Studio, and need to make sure that all rows for one specific bank get the flag-variable set to "N".

Why can't I just map the BANK_ID and BANK_FLAG from the source table, into BANK_FLAG in the target table, then use the following expression?

if BANK_ID = "123456" then do;

  BANK_FLAG = "N";

end;

I also tried this:

case BANK_FLAG

     when BANK_ID = "123456" then "N"

     else BANK_FLAG

end;

I'd appreciate any aid on this rookie problem. Thanks for your time. Smiley Happy

2 REPLIES 2
LinusH
Tourmaline | Level 20

Well, these expression have errors, which you probably encountered!

IF-THEN-ELSE-logic belongs to the data step, not "permitted" in SQL.

A case statement should not end with a ;, that will end the whole CREATE VIEW/TABLE statement.

Is that correct that you already have a BANK_FLAG in the source table, and you just want to change it's value for a specific bank?

Data never sleeps
TurnTheBacon
Fluorite | Level 6

Thanks. Yes, that's correct. I know how to do it in user written code, but apparently not in an SQL Join expression.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 746 views
  • 3 likes
  • 2 in conversation