DATA Step, Macro, Functions and more

How to find hidden character and get rid of it

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

How to find hidden character and get rid of it

I suspect I have hidden character '0A'X, 'M' in the variable.  When I sort and put id on this variable, SAS thinks the same value(to me) are different.  How to find out and change this hidden characters?  The program I run is

proc sort data = meds_new2
 out = meds_new3;
 by All_Managers;
run;
data meds_new4;
set meds_new3;
by All_Managers;
if first.All_Managers then count + 1;
run;

and the output I got is:

Capture.JPGthank you for your help.


Accepted Solutions
Solution
‎04-09-2018 01:23 PM
Super User
Posts: 23,296

Re: How to find hidden character and get rid of it

In addition to @Astounding's suggestion, it's also worth checking the documentation, there's an 'S' modifier in the COMPRESS function to remove all spaces.

s or S adds space characters (blank, horizontal tab, vertical tab, carriage return, line feed, form feed, and NBSP ('A0'x, or 160 decimal ASCII) to the list of characters.

http://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=n0fcshr0ir3h73n1b845c4aq58hz.htm&...

View solution in original post


All Replies
Super User
Posts: 6,632

Re: How to find hidden character and get rid of it

[ Edited ]

If you know what the hidden character is, getting rid of it is easy:

 

all_managers = compress(all_managers, '0A'x);

 

If you don't know what the hidden character is you can find it with:

 

data temp;

set have;

all_managers = compress(all_managers, , 'ad');

run;

proc freq data=temp;

tables all_managers;

format all_managers $hex30.;

run;

 

Contributor
Posts: 41

How to find hidden character and get rid of it

I suspect I have hidden character '0A'X, 'M' in the variable.  When I sort and put id on this variable, SAS thinks the same value(to me) are different.  How to find out and change this hidden characters?  The program I run is

proc sort data = meds_new2
 out = meds_new3;
 by All_Managers;
run;
data meds_new4;
set meds_new3;
by All_Managers;
if first.All_Managers then count + 1;
run;

and the output I got is:

Capture.JPGthank you for your help.

Solution
‎04-09-2018 01:23 PM
Super User
Posts: 23,296

Re: How to find hidden character and get rid of it

In addition to @Astounding's suggestion, it's also worth checking the documentation, there's an 'S' modifier in the COMPRESS function to remove all spaces.

s or S adds space characters (blank, horizontal tab, vertical tab, carriage return, line feed, form feed, and NBSP ('A0'x, or 160 decimal ASCII) to the list of characters.

http://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=n0fcshr0ir3h73n1b845c4aq58hz.htm&...
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 205 views
  • 2 likes
  • 3 in conversation