BookmarkSubscribeRSS Feed
user112a2
Obsidian | Level 7

Do you guys know how to replace remove the comma and period in something like this:

 

Removed

I had to concatenate to get list of claim numbers (with leading zeros). Now, I have that string but I want to delete all the stuff at the end. I tried this but it didn't work

Removed


By the way, I am using SAS and regex, something like prxchange.

2 REPLIES 2
Tom
Super User Tom
Super User

How did you make the string to begin with?  Why not just fix that step instead?

You can use the FINDC() command to find the last character before the trailing commas and periods start.

data test;
  infile cards dsd truncover;
  input @1 have $100. @1 (id1-id20) (:$30.);
  want=catx(',', of id1-id20);
  loc=findc(have,' ,.',-1000,'k');
  want2=substrn(have,1,loc);
  put (_all_) (=/);
cards;
18430109646000104331929350001,064380958490001,974317618110001,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,. 
;

 

have=18430109646000104331929350001,064380958490001,974317618110001,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.
id1=18430109646000104331929350001
id2=064380958490001
id3=974317618110001
id4=
id5=
id6=
id7=
id8=
id9=
id10=
id11=
id12=
id13=
id14=
id15=
id16=
id17=
id18=
id19=
id20=
want=18430109646000104331929350001,064380958490001,974317618110001
loc=61
want2=18430109646000104331929350001,064380958490001,974317618110001

 

ballardw
Super User

@user112a2 wrote:

Do you guys know how to replace remove the comma and period in something like this:

 

'18430109646000104331929350001,064380958490001,974317618110001,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,.,. '

I had to concatenate to get list of claim numbers (with leading zeros). Now, I have that string but I want to delete all the stuff at the end. I tried this but it didn't work

data OUT.REQ_1_4_25 ;
set OUT.REQ_1_4_24;
CONCAT1=PRXCHANGE('s/,.//',1,CONCAT);
run;


By the way, I am using SAS and regex, something like prxchange.


And another reason why I ask every time someone does this "Why?". I have a very hard time understanding what is improved by this time of variable creation unless it is the very last step prior to printing for human readability.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 3162 views
  • 5 likes
  • 3 in conversation