
Department of Statistics
Help for SAS Users in SICL
Printing
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
work.sample1 .
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
delimited.)
data a;
infile "filename" dlm='09'x dsd missover firstobs=2;
input x1 x2 x3;
Explanation:
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;
file 'mydata.txt';
put var1 '09'x var2 '09'x var3 '09'x;
run;
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.
| Description
| Command Line command
|
| Move to Log Window
| log
|
| Move to Program Editor Window
| pgm
|
| Move to Output Window
| out
|
| Save Window Contents to a File
| file "filename"
|
| Clear Window
| clear
|
| Get help with syntax, ie glm
| help glm
|
| Open the Keys Window
| keys
|
| Close a Window
| end
|
| Resize a window
| zoom
|
| End SAS
| bye
|
The following commands can only be used in the program editor window
| Include a file
| inc "filename"
|
| Submit a program
| submit
|
| Recall a program
| Recall
|
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
command line.
Description
| Command
|
| Insert a blank line after the current line
| i or ia
|
| Insert a blank line before the current line
| ib
|
| Delete a line
| d
|
| Delete 5 lines
| d5
|
| Delete a block of lines
| dd on first and last line of the block
|
| Repeat
| 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)
|
| Copy
| c (just like move)
|
| After (used with copy,move, or insert)
| a
|
| Before (used with copy,move, or insert)
| b
|
| Ruler
| cols
|
Programmable Keys
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
| Keys
| Command
| Action
|
| Ctrl+A
| command
| toggles between pmenus and command line
|
| Ctrl+E
| out;clear;log;clear;pgm;sub;log;top
| clears windows and submits job
|
| Ctrl+Y
| print
| print contents of active window
|
| Ctrl+R
| Recall
| Recall previously submitted code
|
| Ctrl+B
| bottom
| Go to bottom of active window
|
| Ctrl+T
| top
| Go to top of active window
|
| Ctrl+P
| pgm
| Go to program editor window
|
| Ctrl+L
| log
| Go to log window
|
| Ctrl+O
| out
| 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
program.
Sample LIBNAME statements
The libref can be any name you choose, but it must be 8 characters or
less.
Desired data storage location (directory)
| Libref
| Appropriate Libname statement
|
| Current working Directory
| current
| LIBNAME current '.';
|
| Your home directory
| home
| LIBNAME home '~';
|
| Your st502 subdirectory
| dir
| LIBNAME dir 'st502'
|
| SAS class subdirectoy
| in
| 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.
Example
| Explanation
| Data set name
| Data current.a;
| SAS data set will be stored in the current working directory
| a.ssd01
|
| 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
| class.ssd01
|
| proc glm data=in.class;
| Perform glm on class data set stored in sasclass_info locker
| class.ssd01
| |
Go to: SAS
Consulting Home Page
Department of Statistics
Home Page
Maintained by: Sandy Donaghy
and Joy Smith
Last Modified: Aug 26, 1998