ERROR: Logical name assigned but not in current scope


The referenced error message indicates that the fileref has been assigned externally and could not be reassigned. This can happen if the fileref was allocated externally and then in the SAS program, a reassign of this fileref is used for a file concatenation.

For example, if allocated in JCL as:

//xxxx DD DSN=userid.TEST.DATA,DISP=SHR

and in the SAS program, a FILENAME statement to concatenate to the fileref is used:

FILENAME xxxx ('userid.TEST.DATA' 'userid.TEST.DATA1');

then the error message will be written to the SAS Log. Processing of the JOB will continue. However, the I/O performed is against the externally allocated reference and not what is defined on the FILENAME statement. The JOB will complete with RC=0.

The SAS system option ERRORCHECK=STRICT must be defined to force SAS to not tolerate this file allocation error. With this option in effect, SAS will set OBS=0 and go into SYNTAX CHECK mode. The job will then complete with RC=8.