Insert decimal (period) after first 3 characters

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Childrensmn
Premium Member
Premium Member
Posts: 32
Joined: Mon Apr 12, 2010 3:42 pm
Location: Minneapolis
Contact:

Insert decimal (period) after first 3 characters

Post by Childrensmn »

I have a varchar column with alpha numeric records. I want to insert a decimal (period) after the first 3 characters. How do I accomplish this in the transformer?

Example
Current Diagnosis_Code
---------------------------
H13132D
78888D
43834

Converted As Diagnosis_Code
-----------------------------------
H13.132D
788.88D
438.34

Thanks!!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Substring. Use the substring operators "[]" to take the first three and the rest of the field and concatenate the period between them. Off the top of my head and without any kind of syntax check:

Code: Select all

Current Diagnosis_Code[1,3] : '.' : Current Diagnosis_Code[4,999]
That final size isn't important and won't error if it is 'too long' but you could always use the real size, even if it is not always known - that's what the length function is for. :wink:
Last edited by chulett on Wed Aug 12, 2015 12:23 pm, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Childrensmn
Premium Member
Premium Member
Posts: 32
Joined: Mon Apr 12, 2010 3:42 pm
Location: Minneapolis
Contact:

Post by Childrensmn »

Works great. Thank You.
Post Reply