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

Hi everyone,

 

im a beginner and i try to substr some adresses.

Result should be cutted aber 6 digits after the comma.

 

input

Musterstr. 1b, 12345 Musterstadt

 

output:

Musterstr. 1b, 12345

 

i tried

substr (t1.adress, findc (t1.adress,",")-0)

 

any ideas how to solve to start the substr 6 digits after the comma?

 

thanks for your help.

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Try this

 

data test;
   str = 'Musterstr. 1b, 12345 Musterstadt';
   new = substr(str, 1, find(str, ',') + 6);
run;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Try this

 

data test;
   str = 'Musterstr. 1b, 12345 Musterstadt';
   new = substr(str, 1, find(str, ',') + 6);
run;
selchen
Calcite | Level 5

thanks a lot. it  is working.

 

 

PeterClemmensen
Tourmaline | Level 20
PeterClemmensen
Tourmaline | Level 20

Also, a PRXCHANGE Approach. 

 

hope this helps 🙂

 

data test;
   str = 'Musterstr. 1b, 12345 Musterstadt';
   new = prxchange('s/(.*,.{6})(.*)/$1/', -1, str);
run;
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
  • 1157 views
  • 0 likes
  • 2 in conversation