简体   繁体   中英

Character conversion from SAS to TERADATA

I have recently started a new job and I am using tools which I am not very familiar with. so i was wondering if the StackOverFlow family could help me out.

I have this concatenation in SAS, but I am not able to sort it out on TERADATA

t1.COD_CZ||PUT(INPUT(t1.CODTC,5.),z4.)||PUT(t1.PROGOPE,z8.) as CODIGO_MCT

I have written something like this, but then the length of the string is not harmonized with the the result in sas.

t1.COD_CZ|| cast(cast(t1.CODTC as int) as char(4))|| cast(t1.PROGOPE as char(8)) as CODIGO_MCT

Can you gently enlight me? thanks in advance

You must apply a FORMAT to get leading zeroes (concatenating trims trailing spaces):

t1.COD_CZ||Cast(t1.CODTC AS FORMAT '9(4)')||Cast(t1.PROGOPE AS FORMAT '9(8)')

The result has a fixed length, but it's still a VarChar(17). If you need fixed length, eg for export:

CAST(t1.COD_CZ||Cast(t1.CODTC AS FORMAT '9(4)')||Cast(t1.PROGOPE AS FORMAT '9(8)') AS CHAR(17))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM