Hello,
My table is composed of "Centre Financier", which identifies the city where customers clients are traited.
On "date de bascule", il shows when the "Centre Financier" has changed.
The "Centre Financier " changes to " CF après bascule" when these conditions are combined :
the 3 last numbers of "numero de compte " are equal to "Code CF"
AND
the 2 first numbers of BGP are equal to "BGP begin"
AND "date derniere maj operation" >= "date de bascule"
Can you help me we CASE / END solution please?
SUBSTR does not accept negative numbers. Also your attempted syntax would have meant "start at position 1 and go back 2"
Here is an example of how to get the last 2 characters from a string using SUBSTR
data example;
x= 'Some string of texz';
y= substr(x,length(x)-1,2);
run;
This works by using the number of characters up to the last non-blank character. The LENGTH function would return the position of the Z in the example text. So we back up one position using -1 to get the position of the X. Then the 2 says to return 2 characters. This last may be needed if your string variable actually has trailing blanks though that isn't generally a concern if the only use is comparison as SAS will treat "33 " as equal to "33".
It helps if show a few records of input data and what the desired result looks like. Make sure the example shows at least one record for each type of issues. It helps if the example data is in the form of datastep code to provide something we can test code with.
@ballardw, hello is it good what I join?
@ballardw, I try to make a filter with SUBSTR on the last two caracters but it gives me nothing...is it the good code?
SUBSTR does not accept negative numbers. Also your attempted syntax would have meant "start at position 1 and go back 2"
Here is an example of how to get the last 2 characters from a string using SUBSTR
data example;
x= 'Some string of texz';
y= substr(x,length(x)-1,2);
run;
This works by using the number of characters up to the last non-blank character. The LENGTH function would return the position of the Z in the example text. So we back up one position using -1 to get the position of the X. Then the 2 says to return 2 characters. This last may be needed if your string variable actually has trailing blanks though that isn't generally a concern if the only use is comparison as SAS will treat "33 " as equal to "33".
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.