SAS on Unix/Linux- from the terminal to GUI.

advertisement
SAS on Unix/Linux- from the terminal to GUI.
L Gakava & S Kannan – October 2015
Agenda
All about the terminal
o 
o 
o 
o 
o 
Customising your terminal
Basic Linux terminal commands
Running SAS in non-interactive mode
Available SAS file editors
What to look out for on Unix/Linux platform
All about Graphical User Interface (GUI)
o 
o 
o 
o 
Launching SAS GUI.
Changing SAS default behaviour
SAS ToolBox commands
SAS editor commands.
Motivation - Why Use SAS On Unix/Linux?
Using SAS on UNIX/Linux Platform
o  Company migrating to UNIX/Linux
o  Joining a company which is using SAS on the Linux platform
Challenge
Too many commands to learn!
Why Use SAS On Unix/Linux
o  Customising Linux sessions will ensure you increase work efficiency by taking
advantage of the imbedded Linux tools. In general transferring and running large files
will be quicker in Linux compared to PC*.
Terminal
What to expect when you login?
% pwd
/home/username
% ls
Customise: Update .bashrc file with this line PS1='$IV
$PWD$EE> ' will change your prompt to show the
following:
/home/username>
Terminal Navigation
Command
Meaning
ls
list files and directories
ls -a
list all files and directories
mkdir
make a directory
cd directory
change to named directory
cd
change to home-directory
cd ~
change to home-directory
cd ..
change to parent directory
Terminal Navigation
Command
Meaning
cp file1 file2
copy file1 and call it file2
mv file1 file2
move or rename file1 to file2
rm file
remove a file
rmdir directory
remove a directory
cat file
display a file
less file
display a file a page at a time
head file
display the first few lines of a file
tail file
display the last few lines of a file
grep 'keyword' file
search a file for keywords
wc file
count number of lines/words/
characters in file
Terminal useful commands
How do you find out if a version of a file has changed?
/home/username>diff file1.txt file2.txt
Command to compare two files.
This is useful to compare outputs that have been re-run with an older
version. This will compare line by line, hence it’s only useful to
compare different versions of the same file. This command cannot
be used to compare datasets.
Terminal useful commands
How do I search for text in multiple files?
/home/username>grep -i <string filename>
How do I run SAS in non-interactive mode/batch?
/home/username>sas <filename>
How do I run code that is resource intensive?
/home/username> sas –memsize max mysascode.sas
Editing SAS files
How do I edit SAS files?
Linux editors for plain text can be divided into two
categories:
1.  Console text editors- include emacs, jed, nano, pico
and vim.
2.  Graphical GUI editors - include gvim, gEDIT, Nedit,
Slick edit, Tea and Sublime
The advantage of the GUI editor is intuitive user friendly interface while the
benefit of the console text editor is the suitability over long distance
network connections which may or may not provide suitable bandwidth
or reliability which would both be required by the GUI editors for remote
operation. Console based text editors. GUI editors Face to face meeting
or teleconference.
What to look out for?
LINUX platform is case sensitive and file directories and external file
names called within SAS are case sensitive but the SAS session is
not.
Code written in PC SAS might not run on SAS because the Microsoft
Windows and Linux operating systems store text files in a different
format. It is good practice convert a file from Microsoft Windows to
Linux format by using a ‘dos2unix’ command on the terminal.
/home/username> dos2unix mysascode.sas
Still other things
Other things to keep in mind
Use the ‘&’ at the end of Linux commands. This means the
command will be executed in the background and you can
continue using the terminal. Otherwise you will have to wait
for the command to execute before you can use the terminal.
If you have a 3-button mouse you can copy text by highlighting
the text using your mouse. This automatically copies the text
and you can paste the text by pressing down the wheel on the
mouse.
Terminal help
If in doubt man it!!!
Type man or fman command to access the system's reference manuals. It can be
used to search for occurrences of specific text and other useful functions.
ALL ABOUT GUI
/home/username>sas&
Changing default behavior
Selecting and copying text
Changing default behavior
Truncation of inserted text?
Text is not split at the cursor when you press ENTER or RETURN?
I cannot use PC shortcuts to copy and paste texts?
Modify the entries in the SAS: KEYS window
Changing default behavior
Remember my configuration settings?
SAS ToolBox
Program editor commands
Editing commands
Copy
c[N]
cc
Move
m[N]
mm
Delete
d[N]
dd
Insert
ia[N]
i[N]
ib[N]
Mark 1 or N lines to be copied
Mark boundary of block to be copied
Mark 1 or N lines to be moved
Mark boundary of block to be moved
Mark 1 or N lines to be deleted
Mark boundary of block to be deleted
Insert 1 or N lines after this point
Insert 1 or N lines from this point
Insert 1 or N lines before this point
Other useful editing commands
Changing case
cu[N]
cl[N]
ccu
ccl
mcu
mcl
Change 1 or N lines to upper case
Change 1 or N lines to lower case
Change block to upper case
Change block to lower case
Change marked text to upper case
Change marked text to lower case
Justification
jl[N]
jjl[N]
jc[N]
jjc[N]
jr[N]
jjr
Left justify line to position N
Left justify block to position N
Centre justify to line length N
Centre justify block to line length N
Right justify 1 or N lines
Right justify block
Other useful editing commands
Repetition
r[N]
rr
Indentation
>[N]
>>[N]
)[N]
))[N]
<[N]
<<[N]
([N]
(([N]
Repeat 1 or N times
Repeat block
Right shift 1 or N spaces
Right shift block 1 or N spaces
Right shift destructive 1 or N spaces
Right shift destructive block 1 or N spaces
Left shift 1 or N spaces
Left shift block 1 or N spaces
Left shift destructive 1 or N spaces
Left shift destructive block 1 or N spaces
CONCLUSION
§  This presentation gives the basis for a less
painful transition to using SAS on Linux
from PC.
o  There is greater flexibility in using Linux and the reader
is encouraged to explore this in more detail to increase
their productivity when using SAS on Linux.
References
Assignment.essayshark.com,. (2015). Retrieved 24 September 2015, from
https://assignment.essayshark.com/blog/wp-content/uploads/2015/08/programming-help.png
Computerhope.com,. (2015). Linux and Unix diff command help and examples. Retrieved 22 September 2015,
from http://www.computerhope.com/unix/udiff.htm
Cyberciti.biz,. (2015). How to: Change / Setup bash custom prompt (PS1). Retrieved 22 September 2015, from
http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
Ee.surrey.ac.uk,. (2000). UNIX Tutorial - Introduction. Retrieved 22 September 2015,
from http://www.ee.surrey.ac.uk/Teaching/Unix/unixintro.html
Ippolito, G. (2015). Linux Text Editors. Yolinux.com. Retrieved 22 September 2015,
from http://www.yolinux.com/TUTORIALS/LinuxTextEditors.html
Support.sas.com,. (2015). AUTOSPLIT, AUTOFLOW Command. Retrieved 25 September 2015, from
http://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#a003284265.htm
Support.sas.com,. (2015). Browsing and Editing SAS Data Sets. Retrieved 25 September 2015, from
http://support.sas.com/documentation/cdl/en/fspproc/59583/HTML/default/viewer.htm#a000430506.htm
Support.sas.com,. (2015). Getting Started with SAS in UNIX Environments. Retrieved 25 September 2015, from
http://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#usas.htm
Support.sas.com,. (2015). SAS Windowing Environment in UNIX Environments. Retrieved 25 September 2015, from
http://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#a002460895.htm
Support.sas.com,. (2015). The SAS ToolBox in UNIX Environments. Retrieved 25 September 2015, from
http://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#a000291162.htm
Wikipedia,. (2015). Bash (Unix shell). Retrieved 22 September 2015,
from https://en.wikipedia.org/wiki/Bash_%28Unix_shell%29
Wikipedia,. (2015). Diff utility. Retrieved 22 September 2015,
from https://en.wikipedia.org/wiki/Diff_utility
William Shotts, J. (2015). LinuxCommand.org: Learn the Linux command line. Write shell scripts.. Linuxcommand.org. Retrieved 22 September 2015, from
http://linuxcommand.org/index.php
Www2.ocean.washington.edu,. (2015). Unix Tutorial. Retrieved 22 September 2015,
from http://www2.ocean.washington.edu/unix.tutorial.html#files
Download