Department of Statistics
Help for SAS Users in SICL
Method 1: You can use the print command on the command line. This should
send the contents of your current window to the printer. It should print
2 pages of printout per sheet of paper. You will get numerous error
messages in your log, but it should work.
Method 2: Pull down menus (file-->print) will print 2 pages of printout
per sheet of paper if you set host printing off .
Host printing can be set as follows: View-->Preferences-->Display Manager -->
Host Printing Off (When button is depressed host printing is on.)
Method 3: Save your printout to a file and use the a2ps command. This will
print the file 2 pages per sheet of paper.
For example, a2ps filename .
Method 4: Save your printout to a file and use the lpr command. This will
print the file 1 page per sheet of paper.
For example, lpr filename .
Copying to a DOS diskette
SAS data sets are system specific. Data sets with the
extension .sd2 can be used on the pc, and data sets with the .ssd01 can
be used in this lab.
Text files can be copied to diskette as follows:
mcopy -t unix-file-name a:dos-file-name
Text files can be copied from diskette as follows:
mcopy -t a:dos-file-name unix-file-name
To check the contents of your diskette, type mdir
To remove the disk, type eject
Highlighting, Cutting, & Pasting
By default SAS copies highlighted text to the paste buffer. You can
change this as follows:
View-->Preferences-->Display Manager--> Turn Automatically store
selection off. (Option is off when button is not depressed.)
The Toolbox Window has buttons for cut, copy, paste, and undo.
Using Excel Files
This is much easier in SAS version 6.12 than ever before.
First, when you create your Excel file, use variable names that are 8 characters
or less and start with a letter. SAS will use these names.
Second, save your Excel file as a tab delimited text file.
File-->save as--> Text(OS2orMSDOS)(.txt)
Working with Tab delimited
Method 1: Use the dimport or dexport command.
Convert a tab delimited text file to a SAS data set
The following command, when entered on the command line, will turn the file sample1.txt into the sas data set
dimport "sample1.txt" sample1
Convert SAS data set to a tab delimited text file
This command, when entered on the command line, will turn the SAS data set work.sample2 into
the tab delimited text file sample2.txt.
dexport sample2 "sample2.txt"
Method 2: Use pull down menus, File-->Import or Export--> etc.
Method 3: Use SAS code
Sample code for reading a tab delimited file
(Indicate on the infile statement that the file is tab
infile "filename" dlm='09'x dsd missover firstobs=2;
input x1 x2 x3;
dlm='09'x (means tab delimited)
dsd (means 2 tabs together indicate a missing value)
missover (means do not go to next line to fill the program data vector;
each record is a separate observation)
firstobs=2 (means start reading data from second line. Usually the first line
contains the variable names.)
Sample code for writing a tab delimited text file.
data _null_; set a;
put var1 '09'x var2 '09'x var3 '09'x;
Command line commands
If you login from home, you will not be able to use your mouse or the pull
down menus. Here is a table of command line commands that you will need.
|| Command Line command
| Move to Log Window
| Move to Program Editor Window
| Move to Output Window
| Save Window Contents to a File
|| file "filename"
| Clear Window
| Get help with syntax, ie glm
|| help glm
| Open the Keys Window
| Close a Window
| Resize a window
| End SAS
The following commands can only be used in the program editor window
| Include a file
|| inc "filename"
| Submit a program
| Recall a program
Editing Commands (Line Number Commands)
These commands are typed on top of the line numbers.
Line numbers can be turned on/off by typing numbers on the
|Insert a blank line after the current line
|| i or ia
|Insert a blank line before the current line
|Delete a line
| Delete 5 lines
| Delete a block of lines
|| dd on first and last line of the block
||r or rr or r# ( just like delete)
|Move 1 line
||m (also need a or b to indicate destination)
|Move 5 lines
||m5 (also need a or b to indicate destination)
|Move a block of lines
||mm on first and last line of the block
(also need a or b to indicate destination)
||c (just like move)
|After (used with copy,move, or insert)
|Before (used with copy,move, or insert)
In SAS there are many programmable keys. Every time there is a new
version of SAS, they change. You can program your keys in the keys
window . The keys window can be opened by typing keys on the
command line or with pull down menus Help-->keys.
Popular key definitions
||toggles between pmenus and command line
||clears windows and submits job
|| print contents of active window
||Recall previously submitted code
||Go to bottom of active window
||Go to top of active window
||Go to program editor window
||Go to log window
||Go to output window
Permanent SAS data sets
If you save a SAS data set in one of your directories it is "permanent".
It will remain there until you delete it. To save a SAS data set to your
directory, you must define a libref with a libname statement and
then use it when you create the SAS data set. Remember, a SAS data set is
a binary file, created by a SAS data step or procedure. It is not the
file you created when you entered your data. The file you entered is a text file or SAS
Sample LIBNAME statements
The libref can be any name you choose, but it must be 8 characters or
|Desired data storage location (directory)
||Appropriate Libname statement
|Current working Directory
||LIBNAME current '.';
|Your home directory
||LIBNAME home '~';
|Your st502 subdirectory
||LIBNAME dir 'st502'
|SAS class subdirectoy
||LIBNAME in '/ncsu/sasclass_info';
Using the defined librefs
Notice, several of these data set have the same name, but they
are stored in different directories.
||Data set name
||SAS data set will be stored in the current working directory
|data a; set current.b;
||data set a will be stored in the saswork directory and data b will be
read from the current working directory
|| a.ssd01 and b.ssd01
|proc print data=dir.class;
||print data set class from the st502 directory
|proc glm data=in.class;
||Perform glm on class data set stored in sasclass_info locker
Go to: SAS
Consulting Home Page
Department of Statistics
Maintained by: Sandy Donaghy
and Joy Smith
Last Modified: Aug 26, 1998