Hello,
I would like to remove 000 in the front and two letters in the end in the TempID? Thanks.
data datain;
format TempID $ 200. ;
input TempID & ;
cards;
5648MA
0009463
0004721
6325IL
0065VN
0435KK
;
run;
data datain;
format TempID $ 200. ;
input TempID & ;
cards;
5648MA
0009463
0004721
6325IL
0065VN
0435KK
;
run;
data want;
set datain;
length want $4;
want=prxchange('s/(^000)(\d{4})/$2/',-1, tempid);
run;
Could you please explain the problem more completely and accurately? None of the examples you show has three numbers before the letters. What should we do with values that don't have two letters at the end? Are the two letters always in the same positions?
Sorry for the confusion.
Remove the follow:
1. 000 is always in the front of the four digits number.
2. Two letters are always at the end of the four digits numbers.
I think it might better clean up in two different groups.
data dataout;
format TempID_ $ 200. ;
input TempID_ & ;
cards;
5648
9463
4721
6325
0065
0435
;
run;
I'm afraid I'm totally lost here. Your reply doesn't seem to clarify the problem for me.
data datain;
format TempID $ 200. ;
input TempID & ;
cards;
5648MA
0009463
0004721
6325IL
0065VN
0435KK
;
run;
data want;
set datain;
length want $4;
want=prxchange('s/(^000)(\d{4})/$2/',-1, tempid);
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.