convert

Overview

The convert statement is used to convert values in a column from base-10 to base-16 or vice-versa.

Syntax

convertcolNameto decimal|hex from decimal|hex

The keywords decanddecimaland the keywordshexandhexadecimalare equivalent.

Details

When converting values in a column, the following considerations apply:

  • Values in the column are replaced with the converted values

  • The colName argument must reference an existing column, and may optionally be fully qualified (else the column is assumed to be in the default DSET)

  • If any values in the column are not valid numbers, they will be treated as 0

  • Blank values are ignored

  • The convert statement may be used in the body of a where statement

  • If a value in colName contains a partially correct value such as 123xyz then it will be treated as a number up to the first invalid character, in this case resulting in a value of 123.

  • The hex digits in the original value can be either upper or lower case

  • The hex digits from A-F will be rendered in upper case in the converted output

  • The convert statement only supports integer values (floating points will be treated as floored to the nearest integer)

Example

convert decimal_count from decimal to hex
convert unique_id from hexadecimal to dec

Last updated