DATA Step, Macro, Functions and more

Does • exist?

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

Does • exist?

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


Accepted Solutions
Solution
‎02-06-2018 05:39 AM
Super User
Posts: 8,214

Re: Does • exist?

Posted in reply to AlexMoreton

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


All Replies
Super User
Posts: 2,046

Re: Does • exist?

Posted in reply to AlexMoreton

 get rid of '.' ? sure?

 

new_var=compress(var,'.');
Super User
Posts: 2,046

Re: Does • exist?

Posted in reply to novinosrin

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

Regular Contributor
Posts: 226

Re: Does • exist?

Posted in reply to AlexMoreton
Posting code is necessary to explain possible mistakes. Use compress instead of tranwrd to remove unwanted chars.
Super User
Posts: 6,903

Re: Does • exist?

Posted in reply to AlexMoreton

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;

Solution
‎02-06-2018 05:39 AM
Super User
Posts: 8,214

Re: Does • exist?

Posted in reply to AlexMoreton

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

 

Contributor
Posts: 30

Re: Does • exist?

Thank you Art!

That worked!

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 150 views
  • 2 likes
  • 5 in conversation