Resetting the State of SAS

Background

IML Studio provides a mode of execution for IMLPlus programs called Statement Mode. In Statement Mode, program statements have a cumulative effect and the symbol table is never cleared. DATA and PROC steps in SAS behave similarly to Statement Mode in IML Studio. Each DATA or PROC step has a cumulative effect. If you clear the contents of the SAS Program Editor window and type in some new statements, those new statements are not executed in a clean context.

When Statement Mode is not in effect, IML Studio clears the symbol table each time an IMLPlus program is run. This causes the program to run in a clean context. A problem can arise if an IMLPlus program submits SAS language statements. Clearing the IMLPlus symbol table does not reset SAS to a clean, default state. It is, in fact, very difficult to reset SAS completely to a default state. Instead of attempting to do the near impossible, IML Studio provides a user-extendable mechanism for partially resetting the state of SAS.

The ResetState.sas file

Located in IML Studio's System directory is a text file called ResetState.sas. The default location of this file is

C:\Program Files\SASHome\SASIMLStudio\14.2\System

The ResetState.sas file contains SAS language statements that reset certain areas of SAS back to a default state. For example, the ResetState.sas file contains the SAS statement

libname _ALL_ clear;

to clear all librefs that may have been defined. Each time IML Studio runs an IMLPlus program outside Statement Mode, it first submits the contents of the ResetState.sas file to the SAS server.

The standard version of the ResetState.sas file shipped with IML Studio only contains a few SAS statements. If during your work with IML Studio you wish some aspect of SAS was being reset to a default state, you can edit the ResetState.sas file and add additional SAS statements. If you decide to modify the ResetState.sas file, please be aware of the following:

Clearing the WORK library

One potentially useful addition to the ResetState.sas file you may want to consider is adding statements to delete all the files in the WORK library. This would cause temporary data sets created by one run of an IMLPlus program to be deleted before the next run.

Please be aware that adding this functionality to the ResetState.sas file can be very dangerous if your PC is shared with other users. This is because the ResetState.sas file is not a user-specific file. Also be aware that you would probably not want to delete all the files in the WORK library if your SAS system is configured with the NOWORKINIT or NOWORKTERM options, which instruct SAS not to delete files in the WORK library during initialization or shutdown.

If after considering these warnings you still wish to delete all the WORK files between runs, the statements you need to add to the ResetState.sas file are

proc datasets library=WORK kill nolist;
quit;