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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16
/*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

4 REPLIES 4
Reeza
Super User

What are the rules? 

 

kiranv_
Rhodochrosite | Level 12

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

Jagadishkatam
Amethyst | Level 16
/*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
ybz12003
Rhodochrosite | Level 12

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 729 views
  • 0 likes
  • 4 in conversation