DATA Step, Macro, Functions and more

How to view the SAS log file with over 4GB?

Accepted Solution Solved
Reply
Super Contributor
Posts: 426
Accepted Solution

How to view the SAS log file with over 4GB?

I'm unable to view the SAS log file with over 4GB in either notepad++ or SAS EG. I got the following message when I tried to open the file.

 

File is too big to be opened by notepad++
Job.log is too large to open inside of Enterprise Guide and will be opened externally.

 

I know there is a way to view the file or extract the file via UNIX commands but I would like to know whether there is any other way to view the high volume file apart from UNIX enviornment. 

 

 


Accepted Solutions
Solution
‎03-21-2017 06:10 AM
Super User
Posts: 6,939

Re: How to view the SAS log file with over 4GB?

data mylog;
infile '/sasuser/asapp/Job.log' truncover;
input line $200.;
lineno = _n_;
if index(line,'ERROR');
if _n_ ge 10000 then stop;
run;

will scan through your log and find the ERROR lines (and only those). Since the line numbers are kept, you can then use those to extract excerpts (firstobs=, obs=) from the log.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Super User
Posts: 7,401

Re: How to view the SAS log file with over 4GB?

Why have you ended up with a 4gb log file?  Try turning certain options off (options nomlogic nomprint nosymbolgen), break the log out into concise parts - i.e. modularise your code and output.  It sounds to me like you dumping a whole database out to the log, or doing vasat amounts of macro processing with macro options enabled.

Super User
Posts: 5,083

Re: How to view the SAS log file with over 4GB?

If you have no control over the size of the log file, you could try reading the log into a SAS data set that contains just one variable.  Each line of the log becomes a separate observation.  Then view the SAS data set.

 

You might be well-advised to change the program to break the log file up into pieces.  Use PROC PRINTTO to determine which sections of the log become part of which output file. 

Super User
Posts: 6,939

Re: How to view the SAS log file with over 4GB?

A 4GB log file contains 4 billion characters. Assuming you can check 1000 characters per second, you would need 4 million seconds for this log, or roughly 1000 hours. So this file is useless for human consumption.

I'd simply delete that file and rerun the process that wrote it, and take care to stop it as soon as it starts to write mountains of text, so you can review it as long as it has a reasonable size.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 9,681

Re: How to view the SAS log file with over 4GB?

Data step ?


data _null_;
 infile '/home/xx.log';
 input;
 putlog _infile_;
 if _n_ lt 100 then stop;
run;



Super Contributor
Posts: 426

Re: How to view the SAS log file with over 4GB?

I tried the similar code, but it seems it didn't helped either. There is no difference in the log even if I change the number of iteration from 1000 to 10000 in the following SAS code. Appreciate your help here.

 

Code which I tried is

 

data _null_;
infile '/sasuser/asapp/Job.log';
input;
putlog _infile_;
if _n_ lt 1000 then stop;
run;

Log file :

 

NOTE: The infile '/sasuser/asapp/Job.log' is:
      Filename=/sasuser/asapp/Job.log,
      Owner Name=asapp,Group Name=grp,
      Access Permission=-rwxrwxrwx,
      Last Modified=21Mar2017:20:19:05,
      File Size (bytes)=4516790

1                                                          The SAS System                               09:54 Monday, March 21, 2017
NOTE: 1 record was read from the infile '/sasuser/asapp/Job.log'.
      The minimum record length was 132.
      The maximum record length was 132.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      user cpu time       0.00 seconds
      system cpu time     0.01 seconds
      memory              779.03k
      OS Memory           20652.00k
Super User
Posts: 6,939

Re: How to view the SAS log file with over 4GB?

[ Edited ]

Ahem.

if _n_ lt 1000 then stop;

1 is smaller than 1000, so it stops there.

Change to

if _n_ ge 1000 then stop;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 426

Re: How to view the SAS log file with over 4GB?

Thank you for quick reply and it resolve the issue. Could you please tell me how can we tweak the same code to look for the word 'ERROR:' in log file and if it is there, it have to print till that line in log window. So that I can easily find out the error message and can investigate the issue.

 

I know that findw function is used to look for words, but I'm not sure how to utilize this function for this scenario.

Solution
‎03-21-2017 06:10 AM
Super User
Posts: 6,939

Re: How to view the SAS log file with over 4GB?

data mylog;
infile '/sasuser/asapp/Job.log' truncover;
input line $200.;
lineno = _n_;
if index(line,'ERROR');
if _n_ ge 10000 then stop;
run;

will scan through your log and find the ERROR lines (and only those). Since the line numbers are kept, you can then use those to extract excerpts (firstobs=, obs=) from the log.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 253 views
  • 5 likes
  • 5 in conversation