Hi,
I have a dataset
ID
2000032
2000072
2000092
I want the dataset:
0003
0007
0009
I want to remove first 2digits and last one digit.
Can anyone help in this. thank you
It's hard to generalize from such a small example. Are there always two digits at the start and always one digit at the end? Are the strings always 7 characters? It seems as if all you want is characters 3 4 5 and 6, so this code will work:
new_id=substr(id,3,4);
data have; input ID $; want=prxchange('s/^\d\d|\d\s*$//',-1,id); cards; 2000032 2000072 2000092 ;
data have; input ID $; datalines; 2000032 2000072 2000092 ; data want; set have; id = substr(id,3,4); run;
This code might nicely illustrate that your question suffers from a Maxim 42 issue.
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.