Chapter Contents |
Previous |
Next |
SAS Companion for the OS/2 Environment |
This section illustrates how to use the FILE and INCLUDE commands to access external files. Commands provide the same purpose as the Save As and Open dialog boxes that are discussed in Opening and Saving Files. The method that you use to access external files depends on the needs of your SAS application and on your personal preference.
Using the FILE Command |
For example, if you want to save the contents of the Log window to an external file that is named C:\SASLOGS\TODAY.LOG, you can issue the following FILE command from the Command dialog box; however, the LOG window must be active.
file "c:\saslogs\today.log"
If you have already defined the fileref LOGS to point to the SASLOGS directory, you can use the following FILE command:
file logs(today)In this case, the file extension defaults to .LOG, as shown in Default File Extensions for Referencing External Files with Member Name Syntax.
If you use the FILE command to attempt to write to an already existing file, a dialog box gives you the choice of replacing the existing file, appending the contents of the window to the existing file, or canceling your request.
If you issue the FILE command with no arguments, the contents of the window are written to the file that is referenced in the last FILE command. This is useful if you are editing a program and want to save it often. However, the dialog box that prompts you about replacing or appending appears only the first time that you issue the FILE command with no arguments. Thereafter, unless you specify the filename in the FILE command, it uses the parameters that you specified earlier (replace or append) without prompting you.
Selecting the Save As item from the main SAS window File menu displays the Save As dialog box. This dialog box performs the same function as the FILE command, but it is more flexible in that it gives you more choices and is more interactive than the FILE command. For more information, see Opening and Saving Files.
The FILE command also accepts several options. These options enable you to associate a device with the output file and to control the record format and length. Some of these options are illustrated in Advanced External I/O Techniques. For the complete syntax of the FILE command, see FILE.
Using the INCLUDE Command |
For example, suppose that you want to copy the file C:\SAS\PROG1.SAS into the PROGRAM EDITOR window. If you have defined a fileref SAMPLE to point to the correct directory, you can use the following INCLUDE command from the Command dialog box, assuming the Program Editor is the active window, to copy the member PROG1 into the Program Editor window:
include sample(prog1)
Another way to copy files into your SAS session is to use the Open dialog box. In addition to copying files, the Open dialog box gives you other choices, such as running the program that you are copying. The Open dialog box is the most flexible way for you to copy files into the Program Editor window. For more information, see Opening and Saving Files.
The INCLUDE command also accepts several options. These options enable you to associate a device with the input file and to control the record format and length. Some of these options are illustrated in Advanced External I/O Techniques. For the complete syntax of the INCLUDE command, see INCLUDE.
Issuing the INCLUDE command with no arguments includes the file that is referenced in the last INCLUDE command. If no previous INCLUDE command exists, you receive an error message.
Using the GSUBMIT Command |
gsubmit buffer=default
You can also use the GSUBMIT command to submit SAS statements that are specified as part of the command. For more information about the GSUBMIT command, see SAS Language Reference: Dictionary.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.