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

Hi all,

I've been going through my data and realized that I have " • " scattered in my strings...

I have been trying to get rid of it via TRANWRD. But it just makes no difference...

I then used translate to translate it to my other characters, no changes at all but no error in my log...

does anyone know how to remove it?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Another alternative, rather than guessing what the ascii code might be, is simply to copy and paste it into either the translate or compress function. e.g.:

 

data have;
  length string $80.;
  input string &;
  cards;
this is • that was
my oh • oh my
;

data test;
  set have;
  string=compbl(compress(string,'•'));
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

6 REPLIES 6
novinosrin
Tourmaline | Level 20

 get rid of '.' ? sure?

 

new_var=compress(var,'.');
novinosrin
Tourmaline | Level 20

Oh well,  " • " looks certainly different to " . "

error_prone
Barite | Level 11
Posting code is necessary to explain possible mistakes. Use compress instead of tranwrd to remove unwanted chars.
Astounding
PROC Star

As best I can tell, the character in question has a hex code of 95.  So you should be able to convert those to blanks using:

 

var = translate(var, '20'x, '95'x);

 

You might have to test to see if that's actually the right hex code, since the text has been copied a couple of times before I get to test it.  So here's the type of program you can use:

 

data _null_;

ch = " • ";

put ch $hex8.;

ch = translate(ch, '20'x, '95'x);

put ch $hex8.;

run;

art297
Opal | Level 21

Another alternative, rather than guessing what the ascii code might be, is simply to copy and paste it into either the translate or compress function. e.g.:

 

data have;
  length string $80.;
  input string &;
  cards;
this is • that was
my oh • oh my
;

data test;
  set have;
  string=compbl(compress(string,'•'));
run;

Art, CEO, AnalystFinder.com

 

AlexMoreton
Obsidian | Level 7

Thank you Art!

That worked!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 921 views
  • 2 likes
  • 5 in conversation