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

Hi,

 

I need some help converting this SQL to a Dataflux expression. I am trying to do a comparison between 2 files and old code in SQL used this to compare it. 

 

LEFT(LTRIM(RTRIM(cast(COLUMNA as varchar(1000)))),LEN(COLUMNB)) = COLUMNA

 

LEFT(LTRIM(RTRIM(SUBSTRING( LTRIM(RTRIM(CAST(COLUMNA as varchar(1000)))) , LEN(COLUMNC) + 1  ,LEN(cast(COLUMNA as varchar(1000)))-  (LEN(@COLUMNC) + 1)  ))),LEN(COLUMNB) = COLUMNA

 

Column A is from  File A

Column B is from File B.

Column C is from File B.

 

Please help!

1 ACCEPTED SOLUTION

Accepted Solutions
audrey
SAS Employee

Hello,

Did you try to use the Expression node? The left, len and trim function exist, which could be reused pretty much identically.

 

What is the type of ColumnA in input? Does it need to be changed to a varchar?

  • If not, you can use something like: `ColumnA` = LEFT(TRIM(`ColumnA`),LEN(`ColumnB`))
  • Otherwise, you might want to add a tostring function: `ColumnA` = LEFT(TRIM(tostring(`ColumnA`)),LEN(`ColumnB`))

For the second line, only the substring function doesn't exist, it can be replaced by a combination of LEFT and RIGHT.

 

 

Hope this helps. If you need a more detailed help, do not hesitate to reach out to support.

 

Thanks,

Audrey

 

 

www.sas.comsupport.sas.com
SAS®... THE POWER TO KNOW®

View solution in original post

1 REPLY 1
audrey
SAS Employee

Hello,

Did you try to use the Expression node? The left, len and trim function exist, which could be reused pretty much identically.

 

What is the type of ColumnA in input? Does it need to be changed to a varchar?

  • If not, you can use something like: `ColumnA` = LEFT(TRIM(`ColumnA`),LEN(`ColumnB`))
  • Otherwise, you might want to add a tostring function: `ColumnA` = LEFT(TRIM(tostring(`ColumnA`)),LEN(`ColumnB`))

For the second line, only the substring function doesn't exist, it can be replaced by a combination of LEFT and RIGHT.

 

 

Hope this helps. If you need a more detailed help, do not hesitate to reach out to support.

 

Thanks,

Audrey

 

 

www.sas.comsupport.sas.com
SAS®... THE POWER TO KNOW®

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 1 reply
  • 921 views
  • 0 likes
  • 2 in conversation