Submitting SAS Code

Introduction to Submitting SAS Code

SAS under Windows provides several methods for you to submit your SAS programs for processing. SAS supports a variety of work strategies, whether you run SAS interactively or in batch, and in conjunction with other Windows programs or as a stand-alone application.

Submitting Code from the Enhanced Editor or Program Editor

To submit SAS code that you have typed into the Enhanced Editor or Program Editor window, you issue the SUBMIT command. SAS provides several ways to do this:
  • Press F8 when the editor window is active.
  • Click the Submit toolbar button.
  • Enter submit in the command bar.
  • From the Run menu, select Submit.
You can use the SUBTOP command from either the command line or the Run menu to submit one or more lines of your SAS code. For more information, see SUBTOP Command: Windows.
Note: If you insert tabs while entering data in the DATALINES statement, you might get unexpected results when using columnar input. This issue exists when you use the SAS Enhanced Editor or SAS Program Editior. To avoid the issue, do one of the following:
  • Replace all tabs in the data with single spaces.
  • Use the %INCLUDE statement from the SAS editor to submit your code.
  • If you are using the SAS Enhanced Editor, select Toolsthen selectOptionsthen selectEnhanced Editor to change the tab size from 4 to 1.

Submitting Code from the SAS NOTEPAD Text Editor

SAS enables you to submit SAS code that you have typed into the SAS NOTEPAD text editor. NOTEPAD can be invoked by selecting Toolsthen selectText Editor when the Enhanced Editor is disabled. SAS provides several ways to submit the code in NOTEPAD:
  • Click the Submit toolbar button.
  • Enter submit in the command bar.
  • From the menu, select Runthen selectSubmit.

Running SAS in Batch Mode

Overview of Running SAS in Batch Mode

You can run SAS jobs in batch mode in the Windows operating environment. Place your SAS statements in a file and submit them for execution along with the control statements and system commands that are required at your site.
You can run windowing procedures, such as those that are associated with SAS/GRAPH, SAS/INSIGHT, and SAS/ACCESS software in a batch SAS job.

Submitting a Batch SAS Job

When you run SAS in batch mode, a status window is displayed. The status window displays the job that is running and also the location of the log and procedure output files. The status window remains open until the SAS job is complete.
If you do not want to see the status window while your batch SAS job is running, use the ICON system option to invoke the SAS System so that the status window becomes an icon when your job is running. You can also minimize the status window by clicking Icon when the window appears. The icon shows the busy pointer (usually an hourglass) while the SAS job is running, and then disappears when the job is complete. You can cancel a batch job either by pressing CTRL+BREAK or by clicking Cancel in the status window
The maximum line length is 32767 bytes.
If you want to establish a permanent libref, then enable the STARTLIB system option when you begin the batch job.
You can submit a batch SAS job by using the following methods:
  • Specify the SYSIN system option in the SAS command (issued from the command prompt or in the Run dialog box) and specify the SAS program to submit. For example: C:\SAS\SAS.EXE -SYSIN C:\SAS\PROGRAMS\PROG1.SAS -CONFIG C:\SAS\SASV9.CFG.
  • Right-click to select a file that has either a .SAS, .SS2, SS7, or .SASV7BPGM file extension. From the pop-up menu, select Batch Submit with SAS 9.3.
  • Select and drag your SAS program file icon (for the file that contains the SAS code) in Windows Explorer, and drop the file onto the SAS.EXE file icon or shortcut.

Submitting Code from the Clipboard

Using the Enhanced Editor or the Program Editor, you can submit SAS code that you copied from another Windows application (such as an editor or word processor) or from SAS Help and Documentation. When you copy text from another Windows application, that text is stored in the Windows clipboard.
From the Run menu in the Enhanced Editor or from the Program Editor window, select Submit clipboard. The code is submitted from the clipboard directly to SAS (without appearing in the Enhanced Editor or in the Program Editor window). Notes and results are sent to the SAS Log and to the Output window, respectively. You can still issue the RECALL command (or press F4) to recall the submitted program into the Enhanced Editor or into the Program Editor window.
You can also use the GSUBMIT command to submit SAS code that is stored in the clipboard. For more information, see GSUBMIT Command: Windows.

Submitting Code by Dragging and Dropping

Introduction to Submitting Code by Dragging and Dropping

You can drag SAS programs from other Windows applications onto an open SAS session and submit them. You can also drag files that contain SAS code and drop them onto an open SAS session to submit them.

Dragging Text from Other Windows

If you drag text from another Windows application or SAS window to the Enhanced Editor or the Program Editor window, that text is moved to the window by default. It is not submitted until you press F8 or issue the SUBMIT command.
However, you can override this default action by right-clicking the text to select it and then dragging it (if the application supports nondefault dragging). When you drop the selection onto the Enhanced Editor or the Program Editor window, a menu appears and you can choose between moving the code or copying the code. The menu for the Program Editor also enables you to submit the code.

Dragging Files in an Interactive Session

By using the My Favorite Folders window, you can access files that exist outside the SAS environment. Files that contain SAS code can be dragged into your interactive SAS session for execution. Access the My Favorite Folders window by using the View menu.
If you drop a file that contains SAS code onto the Enhanced Editor window or on the Program Editor window, that code is included in the window (but not submitted). If you drop the file onto the Log or Output window or on a minimized SAS session, the code is automatically submitted.
When you minimize a SAS session, its icon appears on the Windows task bar. You cannot drop a file onto the task bar. Instead, you can drag the file to the SAS icon on the task bar and hold it there, without releasing the mouse button. After about one second, the SAS window resumes its normal size. Then you can drop the file onto the open SAS session.
Dropping the file C:\MYPROG.SAS onto a window (other than the Enhanced Editor or Program Editor windows) of an open SAS session is the same as issuing this command:
gsubmit "%include 'c:\myprog.sas'";
You can submit more than one file at a time by selecting a group of files that contain SAS programs and then dropping them onto the open SAS session. The order in which the programs are run when they are submitted as a group is determined by Windows. Therefore, if order is important, you should drop each program file separately.
If SAS is busy when you drop a SAS program icon, the dropped file is ignored. The only indication that the dropped file was ignored is a warning beep.

Submitting Code Stored in Registered SAS File Types

During installation, the SAS Setup procedure registers certain file types with Windows to invoke specified actions when you double-click those types of objects. For example, files that have a file extension of .SAS are registered as SAS programs. These registered file types are displayed in Windows with a special icon, as shown here: Icon for SAS registered files
When you double-click a file that has this extension (or that has this icon) SAS is invoked and the contents of the file are included in the Enhanced Editor or Program Editor window. The SAS code that is contained in the file is not processed until you submit it (for example, by pressing F8 or by clicking the Submit tool). If you already have a SAS session running, double-clicking a file begins a second SAS session; it does not use the already-existing session.
SAS uses the default configuration file if you start SAS by double-clicking a registered SAS file type, such as .sas or .sas7bpgm.