# Center for Advancing Population Science (CAPS)

## SAS Training and Documents

Welcome to CAPS SAS Training & Documents page. Below is information for CAPS online training.

This training is designed to cover four topics. It is not meant to teach you everything that there is to know about these subjects; this is just a kick-start to get you going!

1. The SAS System software suite contains a wide variety of software products (called SAS for short) that create an all-encompassing data-driven environment. SAS is the “Swiss army knife” of the statistical analyst covering the wide-spread areas of data processing, statistical analysis, graphing, Geographic Information Systems (GIS), Relational Data Bank Management Systems (RDBMS) access and much more. SAS is a combination of high-level, optimized PROCs (a Fourth Generation Language or 4GL) and low-level DATA step programming (a Third Generation Language or 3GL).
2. UNIX/Linux is the operating system of choice for SAS use due to its stability and security.
3. Emacs is a powerful editor and, with the Emacs Speaks Statistics (ESS) package, is tightly integrated with SAS.
4. The last topic involves the details of our local setup here at CAPS.

Basic SAS - Handout (PDF)

Example (PDF)

## Basics

How do I set up a new user account?

How to customize my shell environment?

The original shell environment, sh, is called the Bourne shell, but few people use it anymore except in sh scripts. Several later shells were developed that are more user-friendly, but not as widely available. The Korn shell, ksh, and the Z shell, zsh, are compatible with the Bourne shell, but the original C shell, csh, and the TENEX C shell, tcsh, are not. zsh supports sh by being compatible with the Bourne shell, supports ksh extensions to the Bourne shell and supports many of the convenient features from csh/tcsh. Therefore, zsh is what we use since sh/ksh scripts are more common than csh/tcsh scripts, yet csh/tcsh users should still find their favorite features.

In ~/.zshrc (when you type the ~ character, it expands to your HOME directory), you can set up your own personal environment, such as creating aliases. For example, the default alias for xemacs is:
alias xemacs='run-with-aspell xemacs'

You may want to modify that for your big 24.1 inch LCD monitor:
alias xemacs='run-with-aspell xemacs -geometry 200x68'

How can I run a binary or script program?

Those who are familiar with other operating systems like DOS/Windows or Mac may not be familiar with Unix file permissions. If the file permissions are set incorrectly, when you attempt to run a binary or script named PROGRAM, you will get an error message:
prompt> PROGRAM
Permission denied: PROGRAM

The reason is most likely that the executable permission setting is in the off position. To check, type:
prompt> ls -l PROGRAM -rw-r--r-- 1 user pcor 603244 Nov 17 13:24 PROGRAM

The fourth character, '-', indicates that the executable permission setting is off. To turn the executable permission setting on, type:
prompt> chmod +x PROGRAM

And to verify, type:
prompt> ls -l PROGRAM -rwxr--r-- 1 user pcor 603244 Nov 17 13:24 PROGRAM

Now, you see that the fourth character, 'x', indicates that the executable permission setting is on and you can execute it successfully:
prompt> PROGRAM

prompt> man chmod

How do I delete control characters from a text file?

The tr command allows you to delete characters from a text file as follows:
prompt> tr -d CHARACTERS < input > output

The way you specify CHARACTERS is very flexible. For example, all upper case letters would be '[A-Z]', all lower case letters '[a-z]' and all numbers '[0-9]'. For control characters which are non-printing characters, you specify them by their octal representation:

 Control Character Name Octal Representation ^@ NUL \000 ^A SOH \001 ^B STX \002 ^C ETX \003 ^D EOT \004 ^E ENQ \005 ^F ACK \006 ^G BEL \007 ^H BS \010 ^I HT \011 ^J LF \012 ^K VT \013 ^L FF \014 ^M CR \015 ^N SO \016 ^O SI \017 ^P DLE \020 ^Q DC1 \021 ^R DC2 \022 ^S DC3 \023 ^T DC4 \024 ^U NAK \025 ^V SYN \026 ^W ETB \027 ^X CAN \030 ^Y EM \031 ^Z SUB \032 ^[ ESC \033 ^- FS \034 ^] GS \035 ^^ RS \036 ^_ US \037

To delete all of the control characters (except the necessary ones), you would do the following:
prompt> tr -d '[\000-\010\013\015-\037]' < input > output

If you know that the file you are dealing with is an MS-DOS file and all you need to do is delete CR, see next question/answer.

How do I convert a DOS/Mac file to a Unix file or vice versa?

The tr command allows you to convert characters from a text file as follows (see also Q6.):
prompt> tr FROM-CHARACTERS TO-CHARACTERS < input > output

The way you specify FROM-CHARACTERS and TO-CHARACTERS is very flexible. For example, all upper case letters would be '[A-Z]', all lower case letters '[a-z]' and all numbers '[0-9]'. If all you need to do is convert a text file from DOS/Mac to a Unix file (or vice versa), then you only need to be concerned with certain control characters (which are non-printing characters), that you specify by their octal representation:

 Control Character Name Octal Representation Purpose ^J LF \012 Unix end-of-line ^M CR \015 Mac end-of-line ^M^J CRLF \015\012 DOS end-of-line

To create a Unix text file from a DOS text file, delete the CRs:
prompt> tr -d '\015' < input > output or use the dos2unix command: prompt> dos2unix input output

To create a Unix text file from a Mac text file, change the CRs to LFs:
prompt> tr '\015' '\012' < input > output

To create a DOS text file from a Unix text file, requires the unix2dos command:
prompt> unix2dos input output

To create a Mac text file from a Unix text file, change the LFs to CRs:
prompt> tr '\012' '\015' < input > output

How can I find my big files?

The easiest way is with the biggest.sh script which finds the biggest files on a local file system.  If you want to find the biggest files in the $HOME tree, then you need to run the script from buz: buz% biggest.sh ~ This will create a list of your biggest files so you can remove or gzip them. How can I clean up my nuisance files? There are two scripts to clean up your nuisance files: rmclean, which removes them, and gzclean, which gzips them. For example, to see all the nuisance files in the directory tree foo, type: prompt> rmclean -all -test foo To delete them, type: prompt> rmclean -all foo To gzip all the nuisance files in the directory tree foo, type: prompt> gzclean -all foo For more information, type: prompt> rmclean prompt> gzclean How can I secure my files and directories? There are several Unix commands that can be used to secure files and directories such as chgrp, chmod and umask. Check out the man pages of these commands for more information. Be aware that it is extremely easy to use these commands incorrectly. So, the grpthink command has been created that will secure a directory and all of its files and sub-directories. For more info, type: prompt> grpthink -h How do I 'do-loop'? In all Bourne-compatible shells, like sh, ksh, zsh and bash, you can loop over a list of files very easily, such as: prompt> for i in *.txt prompt> do prompt> echo$i
prompt> cat $i prompt> done In the case where you are only have one command to repeat, in zsh this can be shortened too: prompt> for i in *.txt prompt> cat$i

If you want to loop over some integers, its kind of messy in sh or ksh. However, in zsh and bash, it is conveniently similar to C syntax:

prompt> for ((i=1;i<=5;i++))
prompt> do
prompt> echo $i prompt> done And, in zsh, it can be written even more concisely: prompt> for i in {1..5} prompt> echo$i

How do I change my password?

There are two commands to change your passwords.  The first command is for your Unix account, type:
prompt> passwd

Of course, you need to know your current password to make a new one. To see the details of the passwd command, type:
prompt> man passwd

That may not work very well if you are running XEmacs; if so, then:
M-x man Enter and you will be prompted for the name of the command in the minibuffer.

prompt> smbpasswd

How do I transfer files?

When you want to transfer files between Unix and Windows, the easiest way is to create a network drive on your PC. When you are in an Explorer window such as My Computer, select the Tools menu and choose Map Network Drive. This will bring up a dialog box. You can choose a Drive letter (Z: is the easiest). Then specify the Folder by \\SERVERNAME\USERNAME.

Unless you need to do this all the time, make sure that Reconnect at logon is unticked and then click Finish. You will be prompted for your Unix username and your password (see changing your file-sharing password). Supply them and press OK. This should open a window with your Unix HOME directory. You can transfer files by dragging them to or from this window.

## Compilers

How do I set up my C/C++/Fortran compiler?

Fortran/C/C++ compilers can be used on the command line. But often in bigger projects, this is performed by the following recipe: prompt> configure OPTIONS prompt> make

This recipe assumes that your environment variables have been set up correctly for the compiler that you want to use. To see your current compiler environment settings, the command compenv has been provided:
prompt> compenv

Only Sun Studio Fortran is available. f95 which supports the Fortran 90/95/200x standards and f77 which supports Fortran 77.

Currently, we have two stable compiler sets for C/C++ installed Sun Studio (cc/CC/as) and GCC (gcc/g++/gas). Some projects may require one set of compilers while other projects another. Most free software projects will work with Sun Studio, so that is the default. Occasionally a project will require GCC. To choose GCC: prompt> gnuset

Also, an experimental compiler with bounds checking is being investigated: (bcgcc/bcg++/gas). For more information about bounds checking view the and how to use it, see Network Theory LTD Free Software Manuals and William Bader GCC Bounds Checking Example.

To choose it: prompt> bcset

How do I use GSL?

GSL is a free-software/open-source alternative to IMSL. Currently, GSL v. 1.11 is installed. It works well with XEmacs. The documentation is available in XEmacs; type M-x info or press the Info button. The documentation is in the Scientific Software section; click on gsl-ref. View GNU Reference Manual

Here is an example:
Suppose the program is called chisq.c. XEmacs compiles C programs with the make utility. For that to work, place the following at the end of your program: /*

Local Variables:
compile-command: "make chisq.out"
End: */

From now on when you open this file, XEmacs will know what to do; the first time, however, you will need to manually tell XEmacs what to do.
Type M-:
and at the minibuffer prompt "Eval:", type "(hack-local-variables)" without the quotes and hit return.

You will also need to create a Makefile ([TAB] means hit the tab key):
#Makefile

%.out: %.c Makefile
[TAB] $(CC) -g -o$@ $< -lgsl -lgslcblas -lm So, to compile your program; type M-x compile or press the Compile button. 'xport-dynamic' is undefined GSL? The following error message is indicative of using Sun ld, but passing it options that only GNU ld needs and understands: ld: fatal: entry point symbol `xport-dynamic' is undefined GSL The solution is to not pass the -export-dynamic switch to Sun ld since it is not needed and not recognized. ## Printing How do I print a PDF without Adobe Reader? You can use GhostScript to convert PS/PDF files to many device formats. In this case, we want to convert a PDF file to one of the formats that our printer supports, such as PS: prompt> gs -sDEVICE=psgray -sOutputFile=\|lp -dNOPAUSE -dBATCH file2print.pdf For more information on GhostScript, especially the other device formats that it can convert PS/PDF files to, type: prompt> gs -h How can I view an .eps/.ps/.pdf file? It's often helpful to view an .eps/.ps/.pdf on the screen before printing and perhaps avoid wasting paper. This can be done with the gsview command. To view your file, type: prompt> gsview FILE & where FILE is a graphics file of one of the following types: PS, Encapsulated PS or PDF. Or, if you are using XEmacs and you are editing a .sas program that has created FILE with a GSASFILE statement, press F12 and you will be prompted for your choice of FILE in the minibuffer; when you have finished your selection press Return. Note that there are also PDF-only viewers you might try for PDFs: acroread, evince and xpdf. Problems that you may experience with gsview: 1. gsview will complain about many PS files, particularly those generated by SAS. It's unclear whether this is a gsview bug or due to a bug in the software that produced the PS file. The simplest work-around is to tell gsview to keep quiet. Under the Options menu, check the box next to Ignore DSC. Just telling gsview to not complain doesn't fix the problem though. gsview will display these "buggy" PS, but many of the buttons and keys will not function properly. Usually, anything that has to do with explicit page numbering will not work. The most useful keys under this circumstance are "r" for Redisplay, "+" for Next Page and "F6" for Fit Window. 2. When printing, gsview tries to guess what type of printer you have. Don't let it guess; check the box "PostScript printer" as that is what our copier supports. For printing PS/PDF files to other types of printers, see How do I print a PDF without Adobe Reader? How can I duplex/staple on the CAPS copier? If you have a PS document, then the command for duplex, flipping left to right: prompt> lp -c -o duplex=left FILE.ps ... flipping top to bottom: prompt> lp -c -o duplex=top FILE.ps ... for stapling, there are a myriad of options (make sure that the copier has staples loaded and they are not jammed): Placement Option Top Left -o staple=tleft Top Right -o staple=tright Bottom Left -o staple=bleft Bottom Right -o staple=bright Two at Left -o staple=2atleft Two at Right -o staple=2atright Two at Top -o staple=2attop Two at Bottom -o staple=2atbottom Two at Center -o staple=2atcenter Of course, you can match any duplex type with any staple type that you want. For PDF documents, use Adobe Reader (acroread). Open the Print window, in the upper right you will see a dialog box for the print command which defaults to "/usr/bin/lp -c". In that dialog, add the necessary clauses, e.g. "/usr/bin/lp -c -o duplex=left". For more information about all of the options available, see below: 8.1 Device Options (For quick reference, please use man page command, which is "man c4500".) File Type: Specifies the type of input file. Text file -o text PostScript file -o ps Adobe PDF file -o pdf Others -o nofilter Note: Use of file type options will override the result of this utility's automatic file type detection. Filter Banner Page: Specifies the use of a customized banner page that includes the information containing the user name, host computer name, print job name (file name), date, time stamp and version of the UNIX Printing Solution utility. The filter banner page is off by default until specified by this option. If there are multiple input files on the command line, each will be printed with a filter banner page before it. (Filter Banner Page) -o fbanner Note: no filter banner page is printed if job type is specified. User ID: Specifies the User ID of a print job. A legal User ID is a string of up to 8 alphanumeric characters (a-z, A-Z, 0-9), with no space in between. (USERID) -o userid=(USERID) User Code: Specifies the User Code of a print job. Enter a user code using up to 8 digits(0-9). A user code identifies a group of users and allows you to check the number of sheets printed under each code with SmartDeviceMonitor. User Code can be set up as a default value during the installation of UNIX filter script or use rpconfig command for setup after UNIX filter installation is completed. Password: Specifies the password of a print job. A legal password is a 4-digit number. (PASSWORD) -o password=(PASSWORD) User IDs longer than 8 characters and passwords longer than 4 characters will be truncated. Job Type: Specifies the type of a print job. Normal (default) (no option needed) Sample Print -o jobtype=sample -o userid=(USERID) Locked Print -o jobtype=locked -o userid=(USERID) -o password=(PASSWORD) Document Server -o jobtype=docserver -o filename=(FILENAME) -o password=(PASSWORD) -o username=(USERNAME) Hold Print -o jobtype=hold -o userid=(USERID) -o filename=(FILENAME) Stored Print -o jobtype=stored -o userid=(USERID) -o filename=(FILENAME) -o password=(PASSWORD) Store and Print -o jobtype=storeprint -o userid=(USERID) -o filename=(FILENAME) -o password=(PASSWORD) Note: 'filename' option is only available for Hold Print and Stored Print. It allows user to enter a file name using up to 16 alphanumeric (a-z, A-Z, 0-9) characters (optional). It distinguishes a file from other files. Since it is used until another file name is typed, be careful not to use secret codes like your password. It identifies individual files under 'Document Name' in the job history with SmartDeviceMonitor. Paper Selection/Cover Pages Selection (Text Format Only) Front Cover/LeaveBlank -o jobtype=frontcover -o coversheet=BLANK -o covertray=TRAY# -o inputtray=TRAY# -o itray=auto_off Front Cover/One Side -o jobtype=frontcover -o coversheet=SIMPLEXCOPY -o covertray=TRAY# -o inputtray=TRAY# -o itray=auto_off Front Cover/Both Sides -o jobtype=frontcover -o coversheet=DUPLEXCOPY -o duplex=(top/left) -o covertray=TRAY# -o inputtray=TRAY# -o itray=auto_off Note: Trays available for cover sheet are tray1 through tray4. User Slip Sheet/Leave Blank -o jobtype=userslipsheet -o sliptray=TRAY# -o inputtray=TRAY# -o slipsheet=BLANK -o itray=auto_off User Slip Sheet/Print on Slip sheet -o jobtype=userslipsheet -o sliptray=TRAY# -o inputtray=TRAY# -o slipsheet=COPY -o itray=auto_off Note: Trays available for cover sheet are tray1 through tray4. Orientation: Specifies print orientation (text input files only) Portrait (default) -o portrait Landscape -o landscape Rotated Portrait -o rportrait Rotated Landscape -o rlandscape Note: We are currently supporting landscape orientation for PostScript files. Number of copies: Specifies the number of copies per file to be printed. The number of copies command varies according the Operation systems. The print commands are shown below. IBM AIX 4.x, 5.x -o nn=# Red Hat Linux 7.0 or above -Z nn=# Sun Solaris, HP-UX and SCO OpenServer -n# Collate: specifies whether the print output is collated Off(default) -o collate=off On -o collate=on Resolution: 600 dpi (default) -o resolution=600 ## Internet How can I access MCW/DPH computer services remotely? You can access your MCW email via Microsoft Office Outlook Web Access to Microsoft Exchange on InfoScope, and, at the same address, you can obtain Citrix Access to MCWCORP. How can I identify/delete SPAM emails? Unfortunately, neither dtmail nor evolution attempt to identify SPAM emails. However, there is a free email reader called Thunderbird, T-bird for short, that does a pretty good job; to run it type: prompt> thunderbird & The first time you start T-bird, it will ask you some questions about how to setup your email account. In the first dialogue, "New Account Setup", select "Email account." In the second dialogue, "Identity," enter your name and email address. In the third dialogue, "Server Information," select "IMAP;" the "Incoming Server" and the "Outgoing Server" should both be post.its.mcw.edu. In the fourth dialogue, "User Names," enter your POST username; this is the part of your email address before @mcw.edu. The last dialogue, "Account Name," can be specified as anything that you like; it defaults to your email address. Now you are ready to read your mail. You will be prompted for your POST password; if you check the box "Use Password Manager to remember this password," then you will only have to enter it one time. Hopefully, you are now able to read your email. To identify SPAM, from the Account Settings dialog, select the Junk Settings tab. Check the box "Enable adaptive junk mail controls for this account." When you are reading your email, you will see some messages flagged as Junk with the flame symbol. When a new email arrives, this column has a flame symbol for Junk. To train T-bird to identify SPAM for you, you must accept or reject its identification of a SPAM email message or lack thereof. For example, if you receive a SPAM message that is not flagged as Junk, then press the Junk button (next to the Delete button). From now on, hopefully, when you receive similar SPAM messages, T-bird will identify them correctly. However, if you receive an email message that is incorrectly identified as SPAM, then press the Not Junk button. After awhile, you may notice that you are not needing to correct the SPAM identification very often. If so, then you can accept those identifications and get those annoying messages out of your Inbox for good. To do so, once again, open the Junk Settings; check the box "Move new junk messages to:" and then you have your choice of either "Junk folder on:" or "Other." From now on, when a message arrives that is identified as SPAM, it will be placed in your Junk folder. You will want to review the Junk folder from time to time to make sure that no email messages have been incorrectly identified. Can I use my dtmail folders with T-bird? Yes, but you have to tell T-bird where your dtmail folders are, so do the following: prompt> thunderbird & Once T-bird starts, from the Edit menu select Account Settings. The Account Settings window will open, from the left side pick Local Folders. There is a setting called "Local directory:". T-bird will have defaulted to something other than what dtmail does. Change this setting to "/home/USERNAME/Mail" (without the quotes) and press OK. Exit T-bird and restart it. If you did not store your messages in Mail (which is the default), but rather stored your messages in mailboxes in other directories, there is an added step. Create a new directory for your 'Local Folders' and make that your present working directory. Now call the script local-mbox to create links to your actual mailboxes and pseudo mailboxes for sub-directories as follows: prompt> local-mbox DIRECTORY where DIRECTORY is the root directory of where your dtmail mailboxes are stored. T-bird/Firefox won't start, what to do? Sometimes when these applications crash, or you are logged off unexpectedly, the applications won't start because they "think" that you are still using them. If T-bird won't start, find the following file and remove it: prompt% rm -f$HOME/.thunderbird/*.default/lock

In rare circumstances when that does not help, find the following file and remove it:
prompt% rm -f $HOME/.thunderbird/*.default/.parentlock If Firefox won't start, find the following file and remove it: prompt% rm -f$HOME/.mozilla/firefox/*.default/lock

How can I use dtmail to get my email?

Currently, only the IS department server can be used to access email.

Before starting dtmail, edit your $HOME/.mailrc file to contain the following lines (make sure that these are the only lines that are setting the dtmail variables imapinboxserver, smtpmailserver and sentmailhostname): #begin: these lines configure dtmail to work with the IS email servers set imapinboxserver='imap.mcw.edu' set smtpmailserver='smtp.mcw.edu' set sentmailhostname='mcw.edu' #end Now start dtmail and everything should work as expected. When I use T-bird, why can't I open an attachment? When trying to open an attachment, you may see an error message such as the following: "... could not be opened, because the associated helper application does not exist. Change the association in your preferences." This can usually be fixed by editing the settings in files named mimeTypes.rdf which can be found somewhere under ~/.thunderbird (use "find ~/.thunderbird -name mimeTypes.rdf" to see where; you will usually have two: one in a directory and one in it's sub-directory named US). Typically, an application has been moved or the name of it has changed. For example, suppose the attachment is an MS Word file. This is controlled by the setting: <RDF:Description RDF:about="urn:mimetype:externalApplication:application/msword" NC:path="/usr/bin/soffice" NC:prettyName="soffice" /> Make sure that the path= setting is correct. If not, edit, save and try again. Occasionally, the setting is already correct, but still does not work. This is probably due to a problem with the specific attachment that you received, such as an incorrect MIME type. However, if it is not just the occasional email, but it is not working at any time, then your mimeTypes.rdf file may have some problems that you can't easily find and correct. If so, then backup your mimeTypes.rdf file and copy the originals that were installed with Thunderbird; again find might be of help locating them, but currently they can be found at: /opt/sfw/lib/thunderbird/defaults/profile/mimeTypes.rdf and /opt/sfw/lib/thunderbird/defaults/profile/US/mimeTypes.rdf When I use dtcm, why can't I make an appointment? The most likely possibility is that you are browsing your calendar from a client when your calendar is stored on the server. In this case, creating new appointments is not allowed by default. However, you can specify that you want this functionality by adding a line like the following to your ~/.desksetdefaults file (note that the white space is a tab character): deskset.calendar.UseFNS: ## LaTeX Package graphics Error: Division by 0? This problem with the graphics package has been around a long time, but no one has bothered to fix it. That's probably because there is an easy workaround. Try something like the following: \includegraphics[scale=.37,angle=270,keepaspectratio=true]{FILE} How can I create presentations with LaTeX? There are two classes that are used here: FoilTeX and Beamer. Beamer is easier to use and has a lot more features than FoilTeX although it is compatible with the FoilTeX commands for convenience. The following commands create a PowerPoint-like presentation: \documentclass[landscape,24pt,dvipsnames]{beamer} \usepackage{beamerfoils} \usecolortheme{albatross} \begin{document} \foilhead{First Slide} ... \foilhead{Last Slide} ... \endfoil \end{document} Note that the last command has to be \endfoil. Also, note that including PDF graphics is problematic since the background color of the presentation will over-write the graphics and cannot be changed. The workaround is to convert the graphics to JPEG before including them. View the beamer manual (PDF). How can I create posters with LaTeX? There are several classes that are necessary, but the following should work:\documentclass[b1,landscape]{sciposter} \usepackage{multicol} \title{Reading, Writing and Ritalin: Parents and Teachers Agree that Stimulants are more effective than Behavioral Therapy for treatment of students with ADHD} % Note: only give author names, not institute \author{Rodney Sparapani, MS} % insert correct institute name \institute{Center for Patient Care and Outcomes Research,\\ the Medical College of Wisconsin\\} \email{montypython@mcw.edu} % shows author email address below institute %\date is unused by the current \maketitle % The following commands can be used to alter the default logo settings %\leftlogo[0.9]{logoWenI}{ % defines logo to left of title (with scale factor) %\rightlogo[0.52]{RuGlogo} % same but on right % NOTE: This will require presence of files logoWenI.eps and RuGlogo.eps, % or other supported format in the current directory \begin{document} %define conference poster is presented at (appears as footer) \conference{Conference on Teaching Introductory Statistics,\\ July 14th, 2006, Milwaukee, WI, USA} \maketitle %%% Begin of Multicols-Enviroment \begin{multicols}{3} %%% Abstract \begin{abstract} ... \end{abstract} ... \end{multicols} \end{document} Viewing the results with xdvi is usually not possible for large posters, but Acrobat Reader should be fine. The sizes are as follows (converted from metric to inches):  Size Short Side Long Side a0 32.7444 46.3398 a1 23.1660 32.7444 a2 16.3722 23.1660 a3 11.5830 16.3722 ra0 33.5400 47.5800 ra1 23.7900 33.5400 ra2 16.7700 23.7900 b0 39.0000 55.1460 b1 27.5730 39.0000 b2 19.5000 27.5730 b3 13.8060 19.5000 ## SAS How do I run SAS? Most likely you are using XEmacs to edit your .sas file. If so, then there are some very nice features for running SAS; see the "ESS Commands" towards the end of the first question under XEmacs for more information. Otherwise, you can run SAS from the command-line: prompt> nohup nice sas ROOT &where ROOT is the filename without the extension, i.e. the filename is actually ROOT.sas. "nohup" keeps your command running after you logoff and "nice" tells SAS not to hog all of the resources since you and others may want to run other commands as well. SAS runs SAS v. 9.2 (the only version of SAS available on Godzilla) and it backs up files with the following extensions, if they exist, before running SAS: .sas, .log, .lst, .txt, .rtf, .ps, .eps, .pdf, .jpg, .jpeg, .gif and .tiff. Up to nine different versions of each file are supported; .ROOT.sas.1 is the most recent, .ROOT.sas.2 is the second most recent, etc. This SAS script attempts to detect if you are running the same SAS program multiple times. Where did the SAS documentation go? SAS once again provides its documentation in HTML and PDF form. View SAS documentation PostScript/Encapsulated PostScript with SAS v.9 In SAS v. 9, you may experience problems with PostScript and/or Encapsulated PostScript files that have no linefeeds. There is a simple solution; specify the GEND= parameter as follows: GOPTIONS DEVICE=... GEND='0D0A'X; ## GNU Emacs and XEmacs How do I use the GNU Emacs or XEmacs editor? Where possible, we will refer to GNU Emacs and XEmacs collectively as “emacs”. GNU Emacs and XEmacs are highly customizable open source text editors/application development systems Emacs is free software released under the GNU Public License (GPL). GNU Emacs came first, but it was slow to adopt an X Windows interface. XEmacs was the first version of emacs to take advantage of X Windows which is how it got its name. Later, GNU Emacs was enhanced to take advantage of X Windows too. Emacs is available for nearly all versions of Unix or Unix-like operating systems, such as Linux and Mac OS X, that support X Windows. More recently, Emacs was also ported to MS Windows. GNU Emacs has features that make it better suited to statistics so we prefer it, but we can use XEmacs in a pinch. To start GNU Emacs, type the following at the command prompt: kingkong:~:$ emacs &

To start XEmacs, type the following at the command prompt:

kingkong:~:\$ xemacs &

This will open emacs with an introduction screen that has some useful reminders of important information.

Command Keys

You can perform a lot of operations from the Menu and the Toolbar that are self-explanatory.  Due to the constant mouse movements you may find these inconvenient; key combinations exist for many common operations.  On Sun keyboards, the Alt key is the menu accelerator, e.g., Alt-f displays the File menu.

Modifier Keys

C-KEY means hold down the Control key while pressing another KEY. For example, C-x means hold down Control while pressing x.

Sh-KEY means hold down the Shift key while pressing another KEY.

M-KEY means hold down the Meta key while pressing another KEY. On PC and Mac keyboards, the Meta key is usually the Alt key. On Sun keyboards, Meta keys are usually to the left and right of the spacebar and have a solid diamond symbol. If you don't have a Meta key, you can press Esc,  release, and then press KEY.

Execute an emacs command: M-x COMMAND Enter

Getting out of Trouble

Cancel current command: C-g

Exit Emacs: C-x C-c

File Commands

Open a file or directory: C-x C-f

Toggle files in a directory:
C-c o
M-x dired-omit-toggle

Open a file/URL in the cursor:
C-c f
right mouse button
M-x find-file-at-point

Save a file: C-x C-s

Refresh a file: F2

Toggle read-only status of file: C-x C-q (or middle mouse button click on --%%- in the file/mode status: bottom left)

Text Commands

Undo changes:
C-x u
Undo

Copy region:
C-Insert
Copy

Cut region:
Sh-Delete
C-Delete
Cut

Paste region:
Sh-Insert
Paste

Select whole buffer as region:
C-x h
Props

Cut a rectangle of text:
M-x kill-rectangle
C-x r k

Paste a Cut rectangle of text:
M-x yank-rectangle
C-x r y

Fill paragraph: M-q

Search forward: C-s (Return stops search)

Search backward: C-r (Return stops search)

Search forward w/ wildcards: M-C-s (Return stops search)

Search backward w/ wildcards: M-C-r (Return stops search)

Query-replace: M-% (y for replace, n for no replace, ! for replace all, Return to stop)

Create a portrait .rtf file: C-F1

Create a landscape .rtf file: C-F2

Comment a region:
C-c c
M-x comment-region

Uncomment a region:
C-u C-c c
C-u M-x comment-region

Buffer Commands

Switch to the *shell* buffer: F8

Send Control character: C-q C-KEY

Split window for two views: C-x 2

Unsplit window: C-x 1

Compose an email message: C-x m

Send an email message: C-c C-c

Close a buffer: C-x k

List all buffers: C-x C-b

vi emulation on: M-Esc

vi emulation toggle off/on: C-z (from vi command mode to emacs and back)

Cursor Movement Commands

Move to beginning of line:
C-a
Home

Move to end of line:
C-e
End

Beginning of file:
C-Home

End of file:
C-End

Page down:
PageDown

Page up:
PageUp

Forward word:
M-f

Backward word:
M-b

Help

Emacs tutorial: F1 t

Emacs manuals: F1 i (or using your mouse to click on the "info" icon in the toolbar)

Search for help: F1 a TEXT

Help for a key: F1 k KEY

Help for an Emacs variable: F1 v VARIABLE

Help for an Emacs command: F1 f COMMAND

Help for an Emacs mode: F1 m

Help for all keys currently available: F1 b

Help for a UNIX command: M-x man (this is preferable to typing "man COMMAND" in the *shell* buffer)

ESS Commands

Start R: M-x R

Start Stata: M-x stata

Batch submit a .sas program: F3

Batch submit a highlighted region of a .sas buffer: C-F3

Switch to the .sas buffer: F4

Switch to the .log, refresh and search for errors: F5

Switch to the .lst and refresh: F6

Switch to the .txt and refresh: F7

Open a SAS dataset with PROC FSVIEW: F9

Open a SAS dataset with PROC INSIGHT: C-F9

Switch to the .csv and refresh: F11

View a GSASFILE graph: F12

For more information about ESS, you can read the ESS manual from within emacs by typing F1 i (or using your mouse to click on the "info" icon in the toolbar) and scroll down to "* ESS: (ess). Emacs Speaks Statistics." View the ESS manual.

Fonts and Point Size

There are two ways to do this. The first is probably the easiest.

On the Options menu, select Font. From there you can pick the font that you want. On our system, Lucidatypewriter seems to work well. Now, from the Options menu, select Font Size. From this list, select the point size that you want. You can change these settings until you are satisfied with your choices. Then, from the Options menu, select Save Options to Custom File. From now on this will be your font and point size choice (until you decide to change it again).

Like all X Windows applications, you can specify the fonts/sizes/colors/etc., used by Emacs in ~/.Xresources You can experiment with different settings for emacs at the command line. For example, the menubar font:

You can see a list of the available fonts with: prompt% xlsfonts

prompt% xrdb -merge ~/.Xresources; emacs &
! ~/.Xresources

!Lines starting with ! are comments
! for XEmacs this setting would be the following

## Miscellaneous

What can I do with MS Office documents?

OpenOffice is an open-source, free software project that inherited its source code from StarOffice. To run this program, type:
prompt> soffice &

What Matlab clones are available?

Octave is available:
prompt> octave

Visit the GNU Octave website for more details.

Can I use a USB flash drive with my SunRay?

Yes. When you plug your USB flash drive into your SunRay, an icon with a flash drive logo will temporarily appear on your screen, however, a folder will not pop open. If you are using CDE or JDS, run the following script in a terminal:
prompt> flash &

With JDS, you can also place a link in your scripts folder so that when you right-click on the desktop, you can launch the script:
prompt> cd ~/.gnome2/nautilus-scripts
prompt> ln -s /usr/local/bin/flash

When you are finished, just remove your flash drive.

How can I get help besides this FAQ?

The Unix help utility is "man" and, assuming that the command that you need help on is called COMMAND, type:
prompt> man COMMAND

For example, if you want to know more about "man" itself, type:
prompt> man man

If this FAQ did not answer your question, please send it to Rodney Sparapani at rsparapa@mcw.edu or call (414) 955-8786.

## SAS Help

#### Rodney Sparapani, PhD

Assistant Professor, Institute for Health & Equity and Biostatistics

(414) 955-8786