I am looking to extract from a code in a field the last only three characters - am trying to do this in SAS® Data Studio - Prepare Data.
Using data prep from SAS Viya 3.5
Code in the field can look something like this 265265414TGA
And I want to extract/include only the last 3 characters TGA
I dont want to code this in if possible rather use the options available
Any suggestions - thanks
Hello,
You can do this directly in VA by creating a calculated item with the Substring() operator. If the length of the value is not always the same, you can use GetLength() to determine the length of the value.
Those operators are documented here:
So to get the last three characters from the "Name" column you would do something like,
Substring('Name'n, ( GetLength('Name'n) - 2 ), 3)
I'm sure this can also be done in Data Studio, but I can't tell you offhand how to do it.
Hello,
You can do this directly in VA by creating a calculated item with the Substring() operator. If the length of the value is not always the same, you can use GetLength() to determine the length of the value.
Those operators are documented here:
So to get the last three characters from the "Name" column you would do something like,
Substring('Name'n, ( GetLength('Name'n) - 2 ), 3)
I'm sure this can also be done in Data Studio, but I can't tell you offhand how to do it.
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.
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.