data T; input ID $ L $; Datalines; 1 3/42514 2 11/761 3 350 ;
Hi,
I have a column L with data and I want to extract only numbers after the slash (\). If there's no slash, then the whole number i.e. the output should be
1 42514
2 761
3 350
Is it feasible?
Thank you in advance for your help.
You can use the scan-function to extract a "word" from a string. If the second argument is negative, scan starts from the right side.
data want; set T; newL = scan(L, -1); run;
View solution in original post
Yes, this works!
Is there a way to do it also in proc sql?
The SCAN function works in SAS Proc SQL.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.