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.

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
  • 9 replies
  • 4289 views
  • 0 likes
  • 4 in conversation