University of Louisiana at Lafayette
Computing Support Services

SAS on UCS

SELF-HELP GUIDES > STATISTICS > SAS

Contents

Introduction

Before you can use SAS on UCS, you must activate your UCS account at the Help Desk, SMH 201. You might also need to work in a class directory or reseach directory if you are working with extremely large files.

If you log into a UCS workstation in the lab in the Conference Center 152 or lab in Stephens Hall 109, you can bring up the windows version of SAS and use the mouse and pull down menus. Information on running SAS in a windows environment is described in SAS 9.1 Companion for UNIX Environments and is available online.

This document describes how to create a SAS command file and execute the program in a terminal window on a UCS workstation. The same UNIX commands issued in the terminal window are used in a telnet session from a remote site.

Back to Contents

Product Information

We are running SAS version 9.1.3 on UCS. We are licensing an academic version that includes the following products: BASE, EIS, ETS, GIS, GRAPH, IML, OR, QC, STAT. Check with the SAS consultant (sas@louisiana.edu) for the complete list of SAS software.

Back to Contents

SAS Documentation

Documentation is available online at http://support.sas.com/documentation/onlinedoc/sas9doc.html (SAS 9.1.3 in html or pdf format). Manuals of earlier versions of SAS products are available for checkout from the Help Desk, Stephens 201.

Back to Contents

Executing SAS

  1. Login to a workstation connected to UCS. If the screen is blank, wiggle the mouse, enter clid and password.
  2. Close any open windows (do not minimize). For each open window, click on the button in the upper left corner, click Close.
  3. Right click and hold down the mouse button to bring up the Workspace Menu and then select Tools. Then left click Terminal to bring up a Terminal window.
  4. Whenever you have more than one window open, you can reposition the windows so you can see the contents of both windows (drag the window title to reposition the window, drag the lower right corner of the window to resize the window). You can click on either window to make it the active window (one you can type in).
  5. At this point you can either copy a SAS program from a floppy disk or type your SAS program in the Text Editor window. Follow steps 6 to 10 if you are typing your program. Start at step 11 if you are copying a file from a floppy disk.
  6. Click on the arrow above the Note Pad and Pencil icon on the Front Panel. Click on the Text Editor menu item.
  7. Start typing the SAS program.
  8. After you have typed (part of) the program, save it in your home directory. Click File | Save (needed). This brings up the Text Editor - Save As dialog box. Type the following in the Enter file name: program1.sas (do not put spaces in the filename).
  9. As you continue typing, save your file. Click File | Save (needed). You will not see the Text Editor save as dialog box again.
  10. After you have finished entering the program and saved the file, click on the Terminal window to make it the active window and go to step 15.
  11. If you are going to copy a SAS file from a floppy: insert the diskette into the drive and if necessary click on the Terminal window to make it the active window.
  12. Type mdir a: to see a list of all the files on your floppy.
  13. Type mcopy a:program1.txt program1.sas to copy the file to your directory. You will assign it the file extension .sas as you copy it. The file name should not include spaces.
  14. Type dos2unix program1.sas program1.sas so UNIX will recognize the end-of-line character properly.
  15. Type sas program1 and wait for the command prompt which will appear after the program finishes running. (SAS assumes that the file extension of program1 is .sas; you do not have to type sas program1.sas).
  16. Executing the SAS program results in a program1.log file and (hopefully) a program1.lst file. The log file contains the SAS commands (each line of the program is numbered), any error messages, any warning messages, and additional information such as the cpu time per command, and the page numbers of the output produced for each command. You will also see information such as the number of observations and variables processed. Type ls to see if you have the files.
  17. Examine the log file in the Terminal window. Type less program1.log Press the spacebar to continue down one screen or b to go back a screen. Press q to exit the less command.
  18. As you find errors in the log file, fix the associated commands lines in the program in the Text Editor window (steps 19 - 20).
  19. If you copied the program from the floppy: you need to edit the file in Text Editor. Click on the arrow above the Note Pad and Pencil icon on the Front Panel. Click on the Text Editor menu item. If necessary, click in the Text Editor window to make it the active window (one you can type in). Click File | Open... and select program1.sas file. If you created the file using the Text Editor, click in the Text Editor window to make it the active window.
  20. Edit the command file and save the changes File | Save (needed).
  21. Click in the Terminal window to make it the active window, and run the program again (sas program1), examine the log file, and continue the process of fixing the program until the program is error free. Note: a program can run without error and still give incorrect results!
  22. Before printing the listing file, examine the listing file in the Terminal window (less program1.lst).
  23. Print out the file(s). To print to the Conference Center free printer type: lpr -Pconflp program1.lst To print to the Stephens Hall free printer type: lpr -Psmhxlp program1.lst
  24. Click the EXIT icon on the Front Panel to log off the workstation. Click OK in the Logout Confirmation window.

Back to Contents

Executing SAS in a telnet session

You can work from a PC at home using the programs notepad, ftp, and telnet.

  1. Write the SAS commands file using notepad.
  2. Connect your computer to the internet using the STEP-UP modem pool or another ISP.
  3. Start ftp connecting to a machine in the Conference Center lab. Machine addresses are in the range d1.ucs.louisiana.edu to d116.ucs.louisiana.edu Then ftp the SAS commands file to your UCS account.
  4. Start telnet connecting to a machine in the Conference Center lab. Machine addresses are in the range d1.ucs.louisiana.edu to d116.ucs.louisiana.edu
  5. Type dos2unix program1.sas program1.sas
  6. Type sas program1
  7. Type less program1.log (spacebar to go down a screen, b to go back a screen, and q to quit the command) and note the errors.
  8. Make fixes to the SAS commands file on your PC using notepad and ftp the SAS commands file to your UCS account.
  9. Type dos2unix program1.sas program1.sas Type sas program1 Type less program1.log and note the errors. When the program runs without error, ftp the listing file (program1.lst) to your PC and copy the file into a word processor. Then you can print out the entire file or just print parts.

Back to Contents

Files

Commands Files

Create the SAS commands file with .sas as the file extension.

Data Files

Data can be in the SAS commands file or in a separate file. Type pwd to get the complete pathname of the file. Suppose /home/abc1234/mysas/survey.dat contains the data for the SAS commands file survey.sas Then survey.sas includes the SAS command:

infile '/home/abc1234/mysas/survey.dat';

Permanent SAS Data Sets

If you create or use an existing permanent data set (two part name), you must include a libname statement in the SAS commands file. For example

libname in '/home/abc1234/mysas';
data in.orders;

This example creates a permanent SAS data set called orders.sas7bdat in the directory /home/abc1234/mysas To access the file in another program (and execute proc freq), include the SAS command statements

libname in '/home/abc1234/mysas';
proc freq data = in.orders;

Back to Contents

SAS/GRAPH

This section describes how to direct SAS/GRAPH output to the Sun workstation, to the HP Laser black/white (FREE) printers in Conference Center 152 and Stephens Hall 109. Type man printer for detailed information about printers and printer options.

Sun Workstation

Dev Option

The Sun workstation uses the graphics device xcolor. Include in your SAS commands file the following SAS statement:

goptions reset=all dev=xcolor
any additional graphics options
;

Modify .Xdefaults

When you display a graph on your workstation, by default, the graph displays on one-fourth of the screen. You can display the graph on the entire screen by creating an .Xdefaults file in your home directory. Spelling and case are significant when specifying these resources. The file includes the following lines:

SAS.DMSFont: 10x20
SAS.DMSboldFont: 10x20
SAS.windowUnitType: percentage
SAS.windowHeight : 90
SAS.windowWidth: 90
SAS.maxWindowHeight : 100
SAS.maxWindowWidth: 100

Logout and log back in. Now, the changes to your .Xdefaults file will go into effect.

Running the Program

  1. Bring up a terminal window, if necessary.
  2. cd to the directory containing program1.sas, if necessary.
  3. Type sas program1. It may take a few moments to process the data; then the graph window will appear. Click anywhere on the graph, with the left mouse button, to make the graph window disappear.


Black and White Copy

You can print a graphics file on the free black and white HP Laser postscript printers in the Conference Center and Stephens Hall. Include the following SAS commands in your SAS commands file:

filename gsasfile '/home/abc1234/graph.ps';
goptions reset=all dev=lj5sips gaccess=gsasfile
gprotocol='' gsfmode=replace
autofeed handshake=none
any additional graphics options
;

Use pageview on a SUN workstation to preview your postscript file before printing it to the printer. Type man pageview for further information.

To run the program:

sas prog_name
pageview graph.ps
(to preview on a workstation)
lpr -Pconflp graph.ps (to print in the Conference Center)
lpr -Psmhxlp graph.ps (to print in Stephens Hall)

Back to Contents

Problems

Cannot Find Batch Input File

SAS assumes that your SAS commands file, with extension .sas, is in your current directory. For example, if your current directory contains the SAS commands file test.sas then you type sas test to run the program. If your file is TEST.SAS, you must type the file name and extension (case is significant). Type sas TEST.SAS Likewise, if test.sas is in another directory, you must type the full pathname.

Quota

You have disk space in your home directory and additional disk space in any allocated research or class directories. Make sure that you cd to the directory set up for your SAS commands files and data. You can check your quota (disk space still available) at any time by typing quota -v. This command lists quota on all directories.

If you run out of space, you have several options. You can backup and then delete unnecessary files. You can use the temporary directory (/usr/tmp). As a last resort, you can request additional space. Students must contact their professor. Faculty should contact the Help Desk (SMH 201 482-5516) for additional information.

Back to Contents

Additional Information

For additional information, refer to Additional SAS Topics or contact the Help Desk, Stephens Hall 201; 482-5516.

 



© Copyright 2005 by the University of LOUISIANA at Lafayette
Computing Support Services, P.O. Box 42770, Lafayette LA 70504
Phone: 337/482-5516 · E-Mail: helpdesk@louisiana.edu