BookmarkSubscribeRSS Feed
Mozer19
Fluorite | Level 6

Mozer19_1-1725369261786.png


Following image exemple, I have a special chars "FF" in 113º line.
So, I can't resolve this in infile statment.
I used code bellow, but isn't works.

DATA linhao;
	    INFILE "&sysparm" ENCODING="UTF-8"  TRUNCOVER LRECL=341 OBS=1000;
		input
			@1  linhao $500.

			;
RUN;

I need a help!


6 REPLIES 6
Tom
Super User Tom
Super User

I don't think 'FF'x is a valid UTF-8 character.

You can use ENCODING='ANY' to tell SAS to not attempt to transcode the characters at all.

Once you have the FF in the value of a SAS variable you can decide what to replace it with.

Then if you did need to attempt to transcode the other bytes from UTF-8 to some other encoding you could use the KCVT() function.  But remember that there are many more possible characters in UTF-8 encoding than can fit into any the 256 possible values recognized by any single byte encoding such as WLATIN1 or LATIN1.

Mozer19
Fluorite | Level 6

I try to used another ecodings but isn't work too.
I need to remove "FF" , so I not found "Feed Form" documentation by SAS Community.

 

Can you knows to resolve "FF" INPUT Statement?

Tom
Super User Tom
Super User

The hex code for a Form Feed is '0C'x not FF.  Perhaps the photograph you showed was of some tool that displayed the Form Feed character as the little FF character.

 

So if you are reading in an text report, like a SAS log file, that has form feed characters at the start of each new page then you should be able to remove them.  For example just using the COMPRESS() function.  But you might also want to count them.

data want;
  infile 'myfile.txt' truncover;
  retain page 1;
  input line $char133.;
  if line=:'0C'x then page+1;
  line=compress(line,'0C'x);
run;
ballardw
Super User

Does this still show the FF when reading the file?

DATA linhao;
	    INFILE "&sysparm" ENCODING="UTF-8"  TRUNCOVER LRECL=341 OBS=1000  PRINT;
		input
			@1  linhao $500.

			;
RUN;

Or look at the TERMSTR= options. You don't indicate which operating system you are running or what operating system created the file. The TERMSTR= can tell Windows that the file was written by Unix (or vice versa).

 

It may also help to share the LOG from running the code to see if there are any interesting messages.

ClarkLawson
Obsidian | Level 7

Whilst this is more than you are asking, I usually remove non-printable characters from a string with the W modifier in the compress function.

compress(string,'w')
Sarath_A_SAS
Obsidian | Level 7

Can you try....

 

 

DATA linhao;
INFILE "&sysparm" ENCODING="UTF-8" TRUNCOVER LRECL=341 OBS=1000;
INPUT @1 linhao $500.;

/* Replace special character (e.g., FF - form feed) with a space */
linhao = TRANSLATE(linhao, ' ', '0C'x); /* '0C'x is the hexadecimal value for form feed */

/* Alternatively, remove the special character */
linhao = COMPRESS(linhao, '0C'x);
RUN;

 

PROC PRINT DATA=linhao (OBS=5);
RUN;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 505 views
  • 0 likes
  • 5 in conversation