Solved
Contributor
Posts: 28

# Joining string's of different length

Hi Guys,

I find that I am in need of some advice again…

I have to join two tables, t1 has an 11 digit number, t2 is a matching number, but the string is only between 6 and 11 digits.  If starting from the last number in the string (the furthest right number) the numbers will match. i.e.  Both number are formatted as a character (\$12.)

 T1 T2 00000456789 456789 00003456789 3456789 00023456789 23456789

How do I add 0’s to the string in T2 to make it an 11 digit number?  Or is there a better way to join them?

I’m very new to all of this, so if you could explain it as if speaking to a child, that would be great.

paul

Accepted Solutions
Solution
‎09-01-2016 10:52 AM
Super User
Posts: 23,747

## Re: Joining string's of different length

put( var, z11.)

input(var, best12.)

You can either create a new variable and merge using the new variable or do conversion on join condition if using SQL.

Eg:

T1= put(...)

All Replies
Solution
‎09-01-2016 10:52 AM
Super User
Posts: 23,747

## Re: Joining string's of different length

put( var, z11.)

input(var, best12.)

You can either create a new variable and merge using the new variable or do conversion on join condition if using SQL.

Eg:

T1= put(...)

Super User
Posts: 23,747

## Re: Joining string's of different length

You can convert to numeric to implement solution or use repeat to generate number of 0 based on length and concatenate VM,yes.

Untested

Repeat(0, 11-length(t2)) ||  t2

Contributor
Posts: 28

## Re: Joining string's of different length

Hi Reeza, thanks for your input. I worked it out from what you said above. Initially the shorter number was Numeric, I had changed it in a previous step. So I went pack there and padded the 0's to the front and it worked great. thanks for your time, paul
☑ This topic is solved.