For the most part in this workshop, we will work with the DMS. But, to introduce you to all four possibilities, we will do brief exercises using command files, line mode, and standard I/O. Some may prefer using command files to using the DMS, but line mode has very limited application.
sas &
This command starts SAS using the DMS. Several windows
open when SAS initiates.
When you start the DMS you are
placed in the program-editor window. To illustrate how to submit a job
in the DMS, type the following commands in the program editor:
The SAS help facility is available through the DMS and from a browser. But the browser must originate from a udel.edu IP address.
Before using the DMS version, set your default SAS browser by editing a file in your home directory named .Xdefaults Edit the file using pico --
pico ~/.Xdefaults
(Remember the meaning of ~/ )Add the following two lines --
SAS.webBrowser: /usr/lib/netscape-launcher SAS.helpBrowser: /usr/lib/netscape-launcher
To use the DMS version, select Help/SAS Help and Documentation. To access the documentation directly through a web browser, point the browser to http://support.sas.com/onlinedoc/913/docMainpage.jsp and bookmark it.
As an exercise, open the SAS help by selecting the link above. Then select--sas root_nameNote that you do not need to type the extension in the file name (.sas is assumed)
pico contents.sas
This is a UNIX command that starts the pico
editor and instructs it to edit a file named contents.sas. Enter the following commands in the
editor:
key in response to the next question.
To illustrate running SAS, type --
sas contents ls less contents.log less contents.lstThe first command, sas contents, runs sas using the commands in the command file called contents.sas. You don't need to type the extension (.sas), but it will work if you do. The second command lists all the files in your current directory. You should see three files --
contents.sas contents.log contents.lstThe first less command displays contents.log. on your screen. The second less command displays contents.lst on your screen. To maneuver through a file using less, use the following keys:
| q | quit | |
| <SPACEBAR>, d | Down one full screen | |
| b | Back one full screen | |
j,
![]() |
Down one line | |
,
k |
Up one line | |
| G | Go to bottom of the file | |
| g | Go to top of the file | |
| /<string> | Search forward for "<string>" | |
| ?<string> | Search backward for "<string>" | |
| n | Repeat most recent search going in the same direction | |
| N | Repeat most recent search going in the opposite direction | |
| h | Help (q to exit help) | |
| -i | Toggle case sensitive. First use: ignore case differences in searches. Second use: honor case differences again. |
qpr -q smips contents.log
qpr -q smips contents.lst
then fasten them together so you will know what commands
generated the output in the .lst file.
To speed up the work, open two (or more) windows on strauss. Use pico (or any other UNIX editor) to edit the command file. Run the program and view the output in the other window. Since unix commands can be combined onto a single line by separating them with a semicolon (;), you need type the run and view commands just once. Then bring them back with the up arrow (when running T-shell), like this: Start pico in one window, as before --
pico contents.sas
In the other window, run the job and view both outpu files at the same time, like this --
sas contents; cat contents.l?? | less
, type
a matching quote and a semicolon on the current line to close
it.
, just
type it on the current line.
sas -nodms
at your UNIX prompt. This starts sas in line mode, without DMS. Now
type in the same program we have run before --
libname lhsas '~larryh/sasnotes';
proc contents data=lhsas.gss04; run;
This example illustrates the limitations of the line mode - results
flash across the screen so fast they can't be read.
So, line-mode is useful only for small jobs. Try, for example
--
libname library '~larryh/sasnotes';
proc means data=lhsas.gss04;
var sex age persinc;
run;
These results are short enough to be read. Sometimes line mode is useful if you need a number such as a mean or standard deviation to insert into code you are writing. For instance if you want to create a variable which is the square of the deviation of personal income from its overall mean, you might get the mean from an interactive run like this one and plug the result into your SAS program, like this
persincSq = (persinc-32.9957253)**2;
To exit sas, type --
endsas;
(Remember the trailing semicolon.)
Sometimes it is useful to set the standard I/O flag and pipe commands into SAS. This can be useful for debugging and particularly in cases when a program contains many repeats of the same code with some details changed for each instance. The SAS macro language also is useful for repetitive program code and is used much more often than a script. But macros (IMHO) are difficult to debug.
Elementary example piping commands from a file into sas:
cat contents.sas | sas -stdio |& less
This strategy can be useful for debugging. You don't write any files until you eliminate all the bugs. And the saslog and listing (procedure output) are interleaved instead of separated into two files. (The ampersand (&) stands for something different here. It stands for the standard-error output device instead of background running.) SAS writes the saslog to the standard-error device (stderr) and the listing to the standard-out device (stdout).