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

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

1 ACCEPTED SOLUTION
5 REPLIES 5
Pete_Murphy
Fluorite | Level 6

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

Tom
Super User Tom
Super User

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;
Tom
Super User Tom
Super User

I think it is definitely the encoding.

 

Ksharp
Super User

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 .

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 2586 views
  • 4 likes
  • 4 in conversation