BookmarkSubscribeRSS Feed
oht
Calcite | Level 5 oht
Calcite | Level 5

Hi

We have a problem reading a huge file. The sas code only read part of the input records and stop without any error. Further examine the file where the input was stop, we find a symbol 'E S' that halted any further processing. The HEX value is '1A'.  We have tried:

data _null_;

infile fin lrecl=314 truncover;
input @;
_infile_=compress(_infile_,' ','NK');

input  ;
file tst;
put _infile_;
run;

But it does not work. Does anyone has this problem and how to resolve this issue ?

Thanks for all your help


9 REPLIES 9
Linlin
Lapis Lazuli | Level 10

what is the purpose of   "compress(_infile_,' ','NK');"?

oht
Calcite | Level 5 oht
Calcite | Level 5

Suppose to remove all the special char. But it didn't work in this case.

Linlin
Lapis Lazuli | Level 10

if you want to only keep numbers then try:

_infile_=compress(_infile_,,'kd');

if you want to keep both numbers and characters then try:

_infile_=compress(_infile_,,'kda');

oht
Calcite | Level 5 oht
Calcite | Level 5

Hi Linlin,

Your code elminated to many other symbol such as - , which we might need to retain. Besides, if the file come in as a fixed column, then the compress will shift that record left which can be a headache for the input statement.

Anyway, thanks for your input.

art297
Opal | Level 21

Rather than trying to remove the characters, on your infile statement have you tried to include the ignoredoseof option?

DanielSantos
Barite | Level 11

From the LRECL option you've specified I'm guessing that maybe this is a fixed rec size file, am I right?


If so, there's no CR/LF in the file and you have to specify the option recfm=F, then SAS will import everything to the end of each record (314 in length).


Then compress with modifier kpw (keep punction + printable chars) will remove the SUB code (1Ax).


data _null_;

infile fin lrecl=314 truncover recfm=F;

input @;

_infile_=compress(_infile_,'','kpw');

put _infile_;

run;


Cheers from Portugal.


Daniel Santos @ www.cgd.pt

oht
Calcite | Level 5 oht
Calcite | Level 5

Thanks for your code. Our files are comma delimited.

art297
Opal | Level 21

I still vote for trying the ignoredoseof option.  It was incorporated, specifically, to deal with the presence of 1A characters.  Take a look at: http://www.sascommunity.org/wiki/IGNOREDOSEOF_Option

oht
Calcite | Level 5 oht
Calcite | Level 5

You are absolutely right. I tested the code and it works out beautifully. Thanks for your help.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 5771 views
  • 0 likes
  • 4 in conversation