Data Files Non-English Characters in SAS University Edition

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Data Files Non-English Characters in SAS University Edition

I am having some troubles reading in data files when using SAS University Edition.

I am teaching myself SAS using books like The Little SAS Book and its companion of Exercises and Projects (as well as using a bunch of other books).

 

I am having a consistent problem with printing libraries that have non English Characters e.g. ó, ú, ç or ä etc.

These characters appear in a data file that I am reading in. The initial input works fine without any errors but when I try to print out the data I get the following error:

 
ERROR: Invalid characters were present in the data.
ERROR: An error occurred while processing text data.
NOTE: The SAS System stopped processing this step because of errors.

 

I have looked at other similar postings such as the one [here] but can't seem to resolve the issue. It really seems the problem comes from the non-English character being present in the .txt file.

 

Now for some details:

I am Using:

SAS University Edition

Windows 10 version 1703

Firefox 52.0.2 (32-bit)

 

My code:

DATA Big_Companies;
	INFILE '/folders/myfolders/TheLittleSASBook/CodePractice/Chapter02/LogData/BigCompanies.txt';
	INPUT	Ranking 1-5
			Company_Name $ 6-34
			Country $ 35-52
			Sales $ 53-59
			Profits $ 60-68
			Assets $ 69-78
			Market_Value $ 79-88
	;
RUN;

PROC PRINT DATA = big_companies;
RUN;

The Data file is attached:

The Log file is attached:

 

  • Does anyone have any advice on how to print out data in SAS University Edition that contanins non-English characters? Smiley Happy

 

Many thanks in advance, I appreciate the help

 

- Pete


Accepted Solutions
Solution
‎05-01-2017 01:39 AM
Super User
Posts: 6,938

Re: Data Files Non-English Characters in SAS University Edition

Just a guess, but try to add

encoding=wlatin1

in the infile statement. It might be that you get trouble because of the UTF-8 encoding of SAS UE.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎05-01-2017 01:39 AM
Super User
Posts: 6,938

Re: Data Files Non-English Characters in SAS University Edition

Just a guess, but try to add

encoding=wlatin1

in the infile statement. It might be that you get trouble because of the UTF-8 encoding of SAS UE.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 6

Re: Data Files Non-English Characters in SAS University Edition

Sorry I didn't post my thanks note earlier,

Yes, it was definately the encoding, I added in this line of text and it worked perfectly.

I appreciate the help from you and all the others who chimed in.

Pete

Super User
Super User
Posts: 6,500

Re: Data Files Non-English Characters in SAS University Edition

[ Edited ]

That does seem strange.

Is it possible that SAS is using wrong encoding when reading the file?

 

When trying to view your attached files on this site I see that the non-ascii characters make the columns not line up.  Is it possible that by using column input you have truncated a multi-byte unicode character and hence made it invalid?

 

 

Did you try reading the file using modified list mode input instead?

DATA Big_Companies;
  INFILE '/folders/myfolders/TheLittleSASBook/CodePractice/Chapter02/LogData/BigCompanies.txt';
  length Ranking 8 Company_Name $40 Country $20 Sales Profits Assets Market_Value $12 ;
  input ranking company_name & Country & sales -- market_value;
run;
Super User
Super User
Posts: 6,500

Re: Data Files Non-English Characters in SAS University Edition

I think it is definitely the encoding.

 

Super User
Posts: 9,681

Re: Data Files Non-English Characters in SAS University Edition

Change another ODS destination ?

 

DATA Big_Companies;
	INFILE '/folders/myfolders/BigCompanies.txt';
	INPUT	Ranking 1-5
			Company_Name $ 6-34
			Country $ 35-52
			Sales $ 53-59
			Profits $ 60-68
			Assets $ 69-78
			Market_Value $ 79-88
	;
RUN;


ods _ALL_ CLOSE;
ods html file='/folders/myfolders/x.htm';
PROC PRINT DATA = big_companies;
RUN;

Open x.htm by hand .

 

☑ This topic is SOLVED.

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

Discussion stats
  • 5 replies
  • 223 views
  • 1 like
  • 4 in conversation