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

Hi,

 

If i am fetching raw data from external file and it is too heavy to open and there is a junk character in it which is not allowing me too fetch the data then how can we resolve this problem???

 

1 ACCEPTED SOLUTION

Accepted Solutions
TomKari
Onyx | Level 15

Does the log indicate which line the junk character is in?

 

I had a similar problem, and I did this:

 

First of all, figuire out what the issue is by just outputting the line with the junk character, something like (say the problem is in line 637):

 

data _null_;

infile 'blah';

file 'blah';

input;

if _n_ = 637 then put _infile_;

run;

 

Then examine the output file to figure out what the issue with the junk character is, and resolve it. The _infile_ variable can be quite helpful. I can't test it, but I think something like this would work (say your problem is in character 146):

 

data _null_;

infile 'blah';

file 'blah';

length InputRecord $whatever;

input;

if _n_ = 637

then do;

InputRecord = substr(_infile_, 1, 145)||substr(infile, 147);

put InputRecord;

end;

else put _infile_;

run;

 

Some combination of these kinds of operations should get you going.

View solution in original post

2 REPLIES 2
TomKari
Onyx | Level 15

Does the log indicate which line the junk character is in?

 

I had a similar problem, and I did this:

 

First of all, figuire out what the issue is by just outputting the line with the junk character, something like (say the problem is in line 637):

 

data _null_;

infile 'blah';

file 'blah';

input;

if _n_ = 637 then put _infile_;

run;

 

Then examine the output file to figure out what the issue with the junk character is, and resolve it. The _infile_ variable can be quite helpful. I can't test it, but I think something like this would work (say your problem is in character 146):

 

data _null_;

infile 'blah';

file 'blah';

length InputRecord $whatever;

input;

if _n_ = 637

then do;

InputRecord = substr(_infile_, 1, 145)||substr(infile, 147);

put InputRecord;

end;

else put _infile_;

run;

 

Some combination of these kinds of operations should get you going.

komalbatra
Fluorite | Level 6
Thank you..i ll try this code.

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1480 views
  • 1 like
  • 2 in conversation