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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Save the date!
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.