Can someone help in the extracting last three characters of a string...irrespective of the length of the string i should extract last 3 three into new variable......I am attaching the sample number
output should like this.....
Thanks in advance
It means that
length(var)-2 this means from the length of the variable you are going 2 places prior.
for ex: 32-015-10101
length (var)= 12
length(var)-2=10 from 10th position you want to take three characters, which will give you the last 3 chars that is why its -2
if the lenght of the var is 10 then we have to take the characters from 8,9 and 10th position.
substr(var, starting position, no of characters)
to get the starting position we will do length(var) - 2
if you want the last 5 characters then the same will be length(var)-4
If you use reverse function then the entire string will be reversed.
if you take the first 3 characters from the result then we will get the result which is reverse to the actual req output
the result will be like
but he wants the result like
So again we have to apply reverse for the final output to get the desired output
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.