How to read a log file and compile a data?

Reply
Contributor
Posts: 39

How to read a log file and compile a data?

I am trying to read a log file and gather some information for the QA work.

filename _all_ clear;

*input your log file path and names here; filename _log_ "H:\TEST\TESTCASE_QTP_SHOW.log";

data log1;

label editor_line_no ='Line number in SAS LOG'

l_r='Messages on ERRORs, WARNINGs and specific NOTEs';

drop i1 fw string;

retain editor_line_no 0; infile _log_;

input;

editor_line_no =editor_line_no +1; fw=scan(_infile_, 1, '20'x);

if substr(fw, length(fw))=':' then; else goto bottom; %macro _search_(string=);

string = "&string."; i1=index(upcase(_infile_), upcase("&string."));

if i1 then goto write;

%mend _search_;

*check for error messages;

%_search_(string=noteSmiley Happy; *check for note messages;

write:; l_r=_infile_; output;

bottom:;

run;

I am trying to make a datasets with number of rows created from each SQL. I am trying to retrieve just the NOTE: string from the log file and substring the observation where it says observation.

For eg.

NOTE: Table TEST1 created, with 2719 rows and 285 columns.

NOTE: Table TEST2 created, with 109903 rows and 15 columns.

NOTE: Table TEST3 created, with 226 rows and 25 columns.

My plan is to just retrieve Table name and rows.

     Table            ROWS

     TEST1        2719.

Is there a way to create a dataset as above my just scanning though the tables ?

I tried

proc sql noprint;

    create table data as

select nobs into :nobs separated by ' ' from dictionary.tables

    where libname='FRAN' ;

quit;

Thanks

Dev

Super User
Posts: 10,466

Re: How to read a log file and compile a data?

If you want a data set with data set name and number of observations then you want

proc sql noprint;

    create table data as

     select memname, nobs

     from dictionary.tables

    where libname='FRAN' ;

quit;

Though I would use a different name than data...

Contributor
Posts: 39

Re: How to read a log file and compile a data?

7   libname Fran "H:\Query_Result_pass_SAS\db2";

NOTE: Libname FRAN refers to the same physical library as CHASE.

NOTE: Libref FRAN was successfully assigned as follows:

      Engine:        V9

      Physical Name: H:\Query_Result_pass_SAS\db2

28

29   proc sql noprint;

30

31       create table res as

32

33        select memname, nobs

34

35        from dictionary.tables

36

37       where libname='Fran' ;

NOTE: Table WORK.RES created, with 0 rows and 2 columns.

38

39   quit;

NOTE: PROCEDURE SQL used (Total process time):

      real time           0.06 seconds

      cpu time            0.04 seconds

The libarary has 56 members.

Super User
Posts: 3,101

Re: How to read a log file and compile a data?

Try libname = 'FRAN'

Super User
Posts: 10,466

Re: How to read a log file and compile a data?

All of the Libname, memname and variable names values are UPPERCASE in the dictionary tables.

Ask a Question
Discussion stats
  • 4 replies
  • 444 views
  • 0 likes
  • 3 in conversation