BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

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;
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
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;

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
ybz12003
Rhodochrosite | Level 12

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;
PaigeMiller
Diamond | Level 26

I'm afraid I'm totally lost here. Your reply doesn't seem to clarify the problem for me. 

--
Paige Miller
novinosrin
Tourmaline | Level 20
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: Save the Date

 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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 665 views
  • 1 like
  • 3 in conversation