Return to SAS Information
While SAS can be run interactively, it is still easiest (and safest) to run it in another mode. This section describes an interface to SAS using your web browser, and the next section describes using the Unix "batch" system. The Web interface is what we will use in class since you will not have to learn anything about Unix in order to use it. However, if you find yourself using SAS for other purposes (term paper, honors thesis, etc.) the batch system may be the easiest for you.
In order to use the web interface, you will simply click on the link to "Running a SAS program via the Web Interface." For the homework problems I will have an equivalent link titled something like "Run the SAS job for Assignment 2" right on the page for that assignment. The main page for the course also has a link to the WEb interface.
When the web interface comes up, you will have to fill in two boxes (technically this is an HTML form, but you don't have to worry about that) and click a button to run the job.
The first box is for your netid:
Step 1: Enter your netid in the netid box.
Netid :
You will see a text box after the "Netid:" on the real form.
Your netid is what will identify your output as your own, and is unique to you, so be sure to use your netid here.
The second box (further down the form) is where you will enter the SAS commands, in the job box:
Step 2: Enter your SAS job in the job box.
Enter your SAS job in the job box:
You will see a large scrollable text box after the colon on the real form.
There are two ways to enter the job. The first is to type and edit directly in the box. The second (preferred) method is to use a text editor, e.g. Notepad in Windows, to construct your job and then copy/paste it into the job box.
Further down the form, you will see a RUN button to push to submit your job.
Step 3: Run the SAS job.
To run the SAS job click the RUN button.
Running the job may take a few moments. Your browser will show itself to be busy while the SAS job is running. Please be patient.
When the job is completed, you will get a new page which will contain a link to the output file.
Output File:
When the job has finished, a new page will come up with a link to the output file. This is a file which contains both the SAS log and the SAS listing files. Be sure to examine the log file to check for any errors, and then check the listing file (next in the output) to get your results.
Printing Results:
All of your output is in the browser now. You can either print directly from the browser, or use the "Save As" function of the browser to save the output file to disk and open it up in your favorite word processor and print from there.
While SAS can be run interactively, it is still easiest (and safest) to run in "batch" mode. Therefore, you must be familiar with the use of files on your computer system. Basically, a file is like a piece of paper in your notebook or a chapter in a book; a directory is like the notebook or book itself. Here are a few examples of program calls on UNIX, our platform (the prompt % is typed by the computer):
% cp file1 file2 make a copy of file "file1" named "file2"
% more file look at "file" a page at a time
(use long space bar to page forward)
% ls list names of your files in your directory
% ls -l long version of "ls" (has dates of last change)
% emacs file edit "file" using full screen editor "emacs"
% vi file edit "file" using full screen editor "vi"
% rm file remove "file" from your directory
While it is more efficient in the long run to learn an editor (emacs or vi) on our sytem, it is also possible to work from your local computer and use FTP to move files back and forth. There are on-line manual pages for commands. For instance, type man rm to find out more about the rm command. There are several good Unix references on the ATS help pages.
The easiest way to run SAS is to store your commands in a file and then pass that file to the sas program. You can either copy one of your instructor's examples, or create your own using emacs or vi. It is a good idea to get in the habit of using the .sas suffix to identify a file of SAS commands. Other standard suffix conventions include:
myfile.sas sas command file (may have data also) myfile.dat data file (if separate from "myfile.sas") myfile.log log of what sas did with your commands myfile.lst output listing of your successful commands
The myfile name is up to you; use 8 or fewer characters in the name, starting with a letter (a-z). Numbers (0-9) or underscore (_) can be used, but avoid other symbols. (This naming convention applies to SAS variables and datasets as well.) The sas program automatically produces the myfile.log and myfile.lst files for you. All you have to do is type the command
% sas myfile.sas
Usually it takes a little while to run. If instead of giving your file you simply typed
% sas
the computer goes into "interactive mode". This is rather complicated and best left to advanced (or adventurous) users. Avoid for now. If you do type this by mistake, simply type the following:
;endsas;
(Those are semicolons, the key just to the right of the L key. Follow by a RETURN.) This will get you out of SAS safely. Otherwise, yell for help!
NOTE: Always review the log file before looking at the output listing. It is usually short. Lines with NOTE: are fine and can be helpful in tracing transformations and creation of new variables. Lines with ERROR or WARNING should be heeded: look for the problem somewhere ABOVE the identified line.
Examples of SAS can be found The myfile.sas usually contains three kinds of sas "paragraphs" or "steps", namely:
options printer options data data input, transformation and manipulation proc procedures for plotting, regression, etc.
The options, data steps and some procs (numerical and graphical summaries, plots) are described in the SAS/BASICS book. The other procs (regression, analysis of variance and other fancy stuff) are found in SAS/STAT. SAS reads your file in "free" format--use as many spaces or tabs as you like--but requires a semicolon (;) at the end of each "phrase" or "sentence". It is good practice to indent phrases in data or proc "paragraphs" for ease of reading.
Comments can appear anywhere in your program EXCEPT in the middle of data. Comment lines can begin with an "asterisk (*). Alternatively, a comment paragraph can be surrounded by "slash asterisk" (/*/*) and "asterisk slash" (*/).
* this is a comment line /* this is also a comment line */
OPTIONS can only appear as the first line of myfile.sas. Here is a setup for looking on the screen:
options nocenter linesize=80 pagesize=24;
Nice size printer plots do better with the option pagesize=50. Common options include:
nocenter do not center output (flush right instead) linesize=80 set width of page to 80 ls=80 same as linesize pagesize=50 set length of page to 50 ps=24 same as pagesize