Running SAS to analyze the Survey data will involve a cycle of editing a
program file, telling SAS to execute the commands in the file, and
examining the results. Here is an outline of the steps; for these
instructions, suppose you are editing a file named name.sas.
- Login and start emacs
- Use emacs to edit your program file. Open or create a file with
either
C-x C-f name.sas
or C-x d to look at all the existing files in your directory.
Use the up and down arrow to move the cursor on top of the desired file,
and then hit f to open it.
The name of the program file must satisfy a special convention.
Specifically, the name must end with the letters ``.sas''. E.g.,
myfile.sas would be a valid file name, while simply
myfile would not.
- Edit the program.
- Save the edited program file
C-x C-w RETURN (if you want to keep the same name)
or C-x C-w newname.sas RETURN
- Get to a shell command line. There are three ways to do this. I
will tell you two of them:
- Use C-z to suspend emacs. After your SAS program
finishes, you have to type %e on the command line to resume
your emacs session where you left off. I.e., execute tempter%
%e. The advantage of this method is that you don't have to keep
rebuilding your editing situation every time. The disadvantage is that
you have to sit and wait while your SAS program is running.
- Use M-x shell to get a shell process running within
emacs. The advantage of this approach is that you can use C-x
b to switch to another buffer and do other work while the SAS program
is running. This way you can minimize thumb-twiddle time. Doing
M-x shell again will put you back in the shell process buffer
(C-x b *shell* RETURN will also do this). When you are
completely done (i.e., you are ready to logout), type ``exit" on the
command line in the shell process buffer to kill that process, then
C-x k RETURN to kill that buffer.
- Run SAS to execute your program. To do this, type sas
name on the shell command line. I.e., execute tempter% sas
name ) In general, if your program file is named ``name.sas'', you
execute the command ``sas name". The sas program will
automatically look for a file named ``name.sas'' to feed to SAS (if
it doesn't find it, it will complain, and no output files will be
created).
The output from SAS will be saved in two files.
- name.log:
- A file named ``name.log'' will contain diagnostic
information. You should always check this file after every run, to make
sure the program did what you intended (e.g., did you really want to
make a dataset containing zero observations). This file is referred to
as ``the saslog'' for the given SAS program.
- name.lst:
- If statistical procedures requested in your program
produced results, they will be written to a file named ``name.lst''. This
file will not exist if no procedure in your program produced any output.
This can happen if your program includes no statistical procedures. It
can also happen if your program has errors. This file is referred to as
``the listing file" for the given SAS program.
Executing ``sas name" will destroy any pre-existing files named
``name.log" or ``name.lst." This can be convenient if you do not want to
save earlier results. But if it is not what you had in mind, the effect
could be a serious problem. You should rename any saslog or listing
files you want to save, or use a new name for your new ``.sas" program
file.
- Use emacs to look over the saslog and listing files.
C-x C-f name.log
C-x k
C-x C-f name.lst
C-x k
In general, SAS will detect only syntax errors, i.e., typographical
errors and language misuse. SAS will not complain, for example, if you
type ``if v202=0" when you meant to type ``if v2022=0". SAS will do
exactly what you tell it, not what you meant to tell it. This is why you
always need to check the saslog.
- Go back to step (3) (i.e., edit your program file).
- Quit emacs: C-x C-c
- logout from tempter: tempter% logout