DATA Step, Macro, Functions and more

Replace em dashes with en dashes

Accepted Solution Solved
Reply
Super User
Posts: 17,851
Accepted Solution

Replace em dashes with en dashes

What's a quick way to replace em dashes with en dashes in a text string?

data have;

informat text_string $30.;

format text_string $30.;

input text_string $;

cards;

This—is_my_string_em_dash

This-has_a_normal_dash

This-is_another_em—dash

Another_normal_-_dash

;

run;


Accepted Solutions
Solution
‎12-04-2013 02:29 PM
Respected Advisor
Posts: 3,777

Re: Replace em dashes with en dashes

in the code you posted emdash is '97'x

translate(text_string,'-','97'x)

View solution in original post


All Replies
Respected Advisor
Posts: 3,777

Re: Replace em dashes with en dashes

TRANSLATE function.

Super User
Posts: 17,851

Re: Replace em dashes with en dashes

Ok...it shows as EM Dash in text but I guess its actually something else, because that works in example above, but not real data.

Hex4 of  9620

Solution
‎12-04-2013 02:29 PM
Respected Advisor
Posts: 3,777

Re: Replace em dashes with en dashes

in the code you posted emdash is '97'x

translate(text_string,'-','97'x)
☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 665 views
  • 0 likes
  • 2 in conversation