Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAS print ASCII value of special character

Tags:

ascii

sas

I am using the notalnum function in SAS. The input is a db field. Now, the function is returning a value that tells me there is a special character at the end of every string. It is not a space character, because I have used COMPRESS function on the input field.

How can I print the ACII value of the special character at the end of each string?

like image 280
Victor Avatar asked Oct 20 '22 04:10

Victor


1 Answers

The $HEX. format is the easiest way to see what they are:

data have;
  var="Something With A Special Char"||'0D'x;
run;

data _null_;
  set have;
  rul=repeat('1 2 3 4 5 6 7 8 9 0 ',3);  *so we can easily see what char is what;
  put rul=;
  put var= $HEX.;
run;

You can also use the c option on compress (var=compress(var,,'c');) to compress out control characters (which are often the ones you're going to run into in these situations).

Finally - 'A0'x is a good one to add to the list, the non-breaking space, if your data comes from the web.

like image 145
Joe Avatar answered Oct 22 '22 21:10

Joe