[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

Pickup just last 16 digits

i have records like

000000000189766666554444
1111111111114561111111111111
2222222224555555555555555555
44444444444447855555555
8976

i want to pickup just last 16 digits if rows has more then 16 digits else no change required
 so result should be

0189766666554444
4561111111111111
5555555555555555
4444447855555555
8796

Thanks
0
sam2929
Asked:
sam2929
1 Solution
 
Aloysius LowCommented:
you could do something ilke:

data x;
x="1234567890123456";
lenX = length(x);
if (lenX > 16) then
      y=substr(x, length(x) - 15);
else
      y = x;
run;
0
 
sameer2010Commented:
In SQL, try something like this:
drop table #t
create table #t(a varchar(100))
insert into #t values('000000000189766666554444')
insert into #t values('1111111111114561111111111111')
insert into #t values('2222222224555555555555555555')
insert into #t values('44444444444447855555555')
insert into #t values('8976')
select case when LEN(a)< 16 then a else RIGHT(a,16) end as outint from #t

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now