BookmarkSubscribeRSS Feed
0 Likes

"resetline;" as a statement in my sas program re-starts the logfile's line numbering scheme to 1.  The problem occurs because I want to reference errors in my code when I have embedded include statements (which add lines to the log) that offset the numbering.  I want to be able to reference my sas file to correct changes using the line number produced by the log above the error.  I could write in my sas program, say: 

"resetline 17;" (if the line after the include statement is the 17th line)

This would allow me to reference the exact line of code that matches what the log file says.

 

Example : 

sas file:

{many lines of code}

.

%include file1;

%include file2;

 

log's line number is now offset by the number of lines in file1 and 2.

 

3 Comments
zandersen
Calcite | Level 5

@zandersen wrote:

"resetline;" as a statement in my sas program re-starts the logfile's line numbering scheme to 1.  The problem occurs because I want to reference errors in my code when I have embedded include statements (which add lines to the log) that offset the numbering.  I want to be able to reference my sas file to correct changes using the line number produced by the log above the error.  I could write in my sas program, say: 

"resetline 17;" (if the line after the include statement is the 17th line)

This would allow me to reference the exact line of code that matches what the log file says.

 

Example : 

sas file:

{many lines of code}

.

%include file1;

%include file2;

 

log's line number is now offset by the number of lines in file1 and 2.

 


I should conclude that adding the "resetline 17;" after the %include file2 (in the example) would solve the problem.

Quentin
Super User

Call execute gets it's own domain of line numbers.

 

resetline ;
data _null_ ;
  do i=1 to 3 ;
    call execute ('data q ; x=1 ;run ;') ;
  end ;
run ;

data foo ;
run ;

Returns log:

1    data _null_ ;
2      do i=1 to 3 ;
3        call execute ('data q ; x=1 ;run ;') ;
4      end ;
5    run ;


NOTE: CALL EXECUTE generated line.
1   + data q ; x=1 ;run ;

NOTE: The data set WORK.Q has 1 observations and 1 variables.

2   + data q ; x=1 ;run ;

NOTE: The data set WORK.Q has 1 observations and 1 variables.

3   + data q ; x=1 ;run ;

NOTE: The data set WORK.Q has 1 observations and 1 variables.

6
7    data foo ;
8    run ;

NOTE: The data set WORK.FOO has 1 observations and 0 variables.

I wonder if they could add an option to %include to allow it to do similar.  That way you would not need to manually specify which line number you want to reset to, which would be a nightmare to maintain.

 

The concept of line numbers is difficult when you get into generated code via %include, macros, call execute, etc.  

zandersen
Calcite | Level 5
The concept of line numbers is difficult when you get into generated code via %include, macros, call execute, etc.

 


I think this also could be done the same way for macros, using "resetline [currentline #];" right after the macro call.  But yes, that would just help track the line numbers on the original sas file that calls the macro.