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;

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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