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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: