DATA Step, Macro, Functions and more

How to remove the some charater in different positions?

Accepted Solution Solved
Reply
Super Contributor
Posts: 297
Accepted Solution

How to remove the some charater in different positions?

Hello:

 

I would like to remove some charaters from different postions in the string.  Please advice.

 

The data are list below:

lab_den_pcr_perf_1

mhh_cyto_tests_1__cfdna

nad_cert_30

nad_imag_find___abn_cort_gyr

 

And I would like to change them to:

lab_den_pcr_perf

mhh_cyto_tests__cfdna

nad_cert

nad_imag_find

 

 


Accepted Solutions
Solution
‎06-07-2017 12:19 PM
Trusted Advisor
Posts: 1,131

Re: How to remove the some charater in different positions?

[ Edited ]
/*In the below case i am suppressing only the digits whereever they are located in the string*/




data have; input text$100.; cards; lab_den_pcr_perf_1 mhh_cyto_tests_1__cfdna nad_cert_30 nad_imag_find___abn_cort_gyr ; data want; set have; new=prxchange('s/\d+//',-1,text); run;
Thanks,
Jag

View solution in original post


All Replies
Super User
Posts: 17,912

Re: How to remove the some charater in different positions?

What are the rules? 

 

PROC Star
Posts: 258

Re: How to remove the some charater in different positions?

[ Edited ]

As per suggestion of @Reeza , please provide some information, so that someone call help you. I find regular expressions very helpful for this kind of scenarios

Solution
‎06-07-2017 12:19 PM
Trusted Advisor
Posts: 1,131

Re: How to remove the some charater in different positions?

[ Edited ]
/*In the below case i am suppressing only the digits whereever they are located in the string*/




data have; input text$100.; cards; lab_den_pcr_perf_1 mhh_cyto_tests_1__cfdna nad_cert_30 nad_imag_find___abn_cort_gyr ; data want; set have; new=prxchange('s/\d+//',-1,text); run;
Thanks,
Jag
Super Contributor
Posts: 297

Re: How to remove the some charater in different positions?

Thanks for the great suggestion. will looking into the prxchange function.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 124 views
  • 0 likes
  • 4 in conversation