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

Hello SAS guys,

 

When I import the excel file into SAS, the SAS dataset has some special charater string beginning with &#, which the excel file don't have, such as " " ,"&# 8875;", "’".  How can I delete those unwanted strings. It seems there is nothing strange with excel file, however these special string shows up between the space of two words instead of blank space. Any idea is appreciated.

 

my SAS data is :

 

var1

Newton’s seconde law for particles

Newtow’s first law for particales

Region 1

13. Basic Math

4.Instruction and#&8875; Concepts

7.Vibratons#&8875;knowledge

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
You have to be careful how you translate them. For example, on this site:
https://www.w3schools.com/charsets/ref_utf_punctuation.asp
you can see that &#8217 is the single apostrophe or RIGHT SINGLE QUOTATION MARK you need for Newton's.

And the &#160, shown here: https://www.w3schools.com/charsets/ref_html_8859.asp seems to be the non-breaking space.

And the #8875 seems to be some kind of math symbol, as shown here: https://www.w3schools.com/charsets/ref_utf_math.asp.

That form &#xxxx; is an HTML entity and you can look them up on the W3C site.

You might be able to have Excel use the correct entity when it displays the value if you change the font for the sheet to a Unicode font.

Cynthia

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

What method did you use to import the data?  What version of SAS are you using.

I think this issue of some unicode characters being stored this way was fixed in a recent update.

 

You can just use TRANWRD() function to convert them.

160 (or 'A0'x) is a "non-breaking" space.  So just replace it with a space.

8217 is a curly single quote. I would just replace it with a normal single quote.

daisy6
Quartz | Level 8

Hi Tom,

I use SAS 9.4(TS1M3). The import code is proc import datafile="datadir\excelfilename.xlse" out=have dbms=xlsx replace;

getnames=no;

run;

 

Thanks for answering the question

Cynthia_sas
SAS Super FREQ
Hi:
You have to be careful how you translate them. For example, on this site:
https://www.w3schools.com/charsets/ref_utf_punctuation.asp
you can see that &#8217 is the single apostrophe or RIGHT SINGLE QUOTATION MARK you need for Newton's.

And the &#160, shown here: https://www.w3schools.com/charsets/ref_html_8859.asp seems to be the non-breaking space.

And the #8875 seems to be some kind of math symbol, as shown here: https://www.w3schools.com/charsets/ref_utf_math.asp.

That form &#xxxx; is an HTML entity and you can look them up on the W3C site.

You might be able to have Excel use the correct entity when it displays the value if you change the font for the sheet to a Unicode font.

Cynthia
daisy6
Quartz | Level 8

Thank you Cynthia_sas. How can I convert the excel file to a unicode font? The format cells option in excel do not provide unicode choice.

 

daisy6
Quartz | Level 8

Thank you very much. It works.

Ksharp
Super User
data _null_;
x='Newton’s seconde law for particles';
x=htmldecode(x);
put x=;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1168 views
  • 0 likes
  • 4 in conversation