Help using Base SAS procedures

ASCII CODE to convert a character string.

Reply
New Contributor
Posts: 3

ASCII CODE to convert a character string.

Hello,

I have a text string like this : 'UNIT: 10^3/UL’. and it should be converted to ‘UNIT: 10^3/UL’.

The first apostrophie should be changed from " 'UNIT " to " ‘UNIT"

Please let me know how to do this?

Thanks,

Sowmya

Respected Advisor
Posts: 4,173

Re: ASCII CODE to convert a character string.

Posted in reply to sowmyavasa
New Contributor
Posts: 3

Re: ASCII CODE to convert a character string.

Yes, But I dont know the ASCII code for the quote that is mentioned. Both appears to be same ?

PROC Star
Posts: 1,760

Re: ASCII CODE to convert a character string.

Posted in reply to sowmyavasa

Not the same. Look closer.

You can get the code using function rank().

data HAVE;

  X="  'UNIT: 10^3/UL’  ";

  X=translate(X,"’","'");

  A=rank("’");

  B=rank("'");

  put X= / A= B=;

run;

X=’UNIT: 10^3/UL’

A=146 B=39

Super User
Super User
Posts: 7,954

Re: ASCII CODE to convert a character string.

Posted in reply to sowmyavasa

My question would by why do you want quotes of any kind in your data, just looks like extra effort for no gain.  If it needs to be quoted for output purposes then use the quote functions provided, but keep your raw data without these things.

Ask a Question
Discussion stats
  • 4 replies
  • 726 views
  • 1 like
  • 4 in conversation