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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Submit your idea!
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.