STA302/1001 - SAS lecture1 Some Basics of CQUEST The operating system in RW labs (107/109 and 211) is Windows XP. There are a few terminals in RW 213 running.

Slides:



Advertisements
Similar presentations
Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
Advertisements

Create a Web Site with Publisher 2000 for Marilyn Seguins Class.
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Linux, it's not Windows A short introduction to the sub-department's computer systems Gareth Thomas.
Tutorial 8: Developing an Excel Application
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
XP Information Technology Center - KFUPM1 Microsoft Office FrontPage 2003 Creating a Web Site.
Today: Run SAS programs on Saturn (UNIX tutorial) Runs SAS programs on the PC.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 4P. 1Winter Quarter Introduction to UNIX.
MBAC 611.  We have been using MS Access to query and modify our databases.  MS Access provides a GUI (Graphical User Interface) that hides much of the.
Creating a Web Page HTML, FrontPage, Word, Composer.
Designing a Classroom Web Site Using NVU Beginning Level.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Agenda What is Computer Programming? The Programming Process
ITCS 4/5145 Parallel Programming, UNC-Charlotte, B. Wilkinson, 2012, Jan 18, 2012assignprelim.1 Assignment Preliminaries ITCS 4145/5145 Spring 2012.
Project 3 File, Document, Folder Management, Windows XP Explorer Windows XP Service Pack 2 Edition Comprehensive Concepts and Techniques.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Welcome to Linux & Shell Scripting Small Group How to learn how to Code Workshop small-group/
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
®® Microsoft Windows 7 for Power Users Tutorial 13 Using the Command-Line Environment.
ECT 250: Survey of E-Commerce Technology FrontPage Publishing pages Unix.
Unix Tutorial for FreeSurfer Users. Helpful To Know FreeSurfer Tutorial Wiki:
FTP Server and FTP Commands By Nanda Ganesan, Ph.D. © Nanda Ganesan, All Rights Reserved.
1 ITI 1120 Lab # 1 An Introduction to the Lab Environment Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
SAS lecture - week 31 Some Basics of CQUEST The operating system in the ESC lab (1046) is Linux. The operating system in RW labs (107/109 and 211) is Windows.
Unix Tutorial for FreeSurfer Users. Helpful To Know FreeSurfer Tutorial Wiki:
Chapter 1: Introduction to SAS  SAS programs: A sequence of statements in a particular order  Rules for SAS statements: –Every SAS statement ends in.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU Usage of Workstation Lecturer: Yu-Hao( 陳郁豪 ) Date:
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
XP New Perspectives on Windows 2000 Professional Windows 2000 Tutorial 2 1 Microsoft Windows 2000 Professional Tutorial 2 – Working With Files.
Learning How to Make a PowerPoint Presentation A tutorial for novice users.
1 EPIB 698E Lecture 1 Notes Instructor: Raul Cruz 7/9/13.
1May 16, 2005 Week 2 Lab Agenda Command Line FTP Commands Review More UNIX commands to learn File name expansion - * Introduction of vi.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
MySQL Getting Started BCIS 3680 Enterprise Programming.
Introduction to SAS/willow (Unix) Sam Gordji Weir 107.
More on Using onyx 8/28/13. Program 1 Due a week from today. See website for details.
FTP COMMANDS OBJECTIVES. General overview. Introduction to FTP server. Types of FTP users. FTP commands examples. FTP commands in action (example of use).
Practical Kinetics Exercise 0: Getting Started Objectives: 1.Install Python and IPython Notebook 2.print “Hello World!”
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
XP New Perspectives on Microsoft Windows XP Tutorial 2 1 Microsoft Windows XP Working with Files Tutorial 2.
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
Integrity Check As You Well Know, It Is A Violation Of Academic Integrity To Fake The Results On Any.
BIF703 FTP (File Transfer Protocol) Utility vi editor Utility.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
MySQL Getting Started BCIS 3680 Enterprise Programming.
Learning Unix/Linux Based on slides from: Eric Bishop.
Instructions for using this template. Remember this is Jeopardy, so where I have written “Answer” this is the prompt the students will see, and where.
Assignprelim.1 Assignment Preliminaries © 2012 B. Wilkinson/Clayton Ferner. Modification date: Jan 16a, 2014.
Tutorial Six Linux Basics CompSci Semester Two 2016.
Introduction to Unix for FreeSurfer Users
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
CS1010: Intro Workshop.
Andy Wang Object Oriented Programming in C++ COP 3330
Assignment Preliminaries
Windows Internet Explorer 7-Illustrated Essentials
Chapter 1: Introduction to SAS
Getting Started: Developing Code with Cloud9
Getting Started: Amazon AWS Account Creation
Andy Wang Object Oriented Programming in C++ COP 3330
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Running a Java Program using Blue Jay.
CSCE 206 Lab Structured Programming in C
Presentation transcript:

STA302/ SAS lecture1 Some Basics of CQUEST The operating system in RW labs (107/109 and 211) is Windows XP. There are a few terminals in RW 213 running Linux. SAS is run from a Linux Server. Your account is the same and files are accessible in all labs / operating systems. To logout in Linux: look under System To logout in Windows: look under Start To open a web browser in Linux: Firefox is the mouse on a globe icon on the toolbar. In Linux: if you want a terminal window you can either right click on the desktop or click on Applications and then Accessories. If backspace doesn’t work in SAS, turn off Num Lock.

STA302/ SAS lecture2 Accessing CQUEST Remotely In Mac: use an X11 terminal window. The command is: ssh -X -l cquestuserid login.cquest.utoronto.ca In Windows: need PuTTY and Xming (free downloads). All files will be on CQUEST and not on the computer you're working on. So the data file needs to be saved on your CQUEST account and SAS output will be on CQUEST. Use an sftp program to transfer files. For example, to print SAS output at home you'll need to transfer the files to your home computer. (I recommend the sftp programs WinSCP for MS Windows and Fugu for Mac OS X; both can be downloaded for free.)

STA302/ SAS lecture3 Using SAS: Batch vs Window Mode In RW labs SAS run in a Windows mode. In a window mode you can have access to SAS help and have a better control of graphics. On the other hand, SAS help isn’t great and to be able to use Window mode you either need to purchase site license or be in CQUEST lab. If you wish to use SAS on CQUEST from home you will need to use batch mode which require learning some Unix commands.

STA302/ SAS lecture4 A Picture of the SAS Windowing Environment on CQUEST

STA302/ SAS lecture5 Starting SAS Windows Mode In Linux, under Applications choose CQUEST and then SAS or type sas at a command prompt in a terminal window. In Windows, under Start choose Statistics Apps and then SAS. You will have to enter your CQUEST password. Many windows will open including:  a program editor where you type your SAS program.  a log window (. log file)  an output window (. lst file)  An explorer for navigating through your windows and output  a graphic window will open once you have run a program that produces graphic plots (except if the plots are produced using the Output Delivery System (ODS))

STA302/ SAS lecture6 Starting SAS Windows Mode Remotely When accessing CQUEST remotely: type sas at a command prompt. You will have to enter your CQUEST password. Double-clicking on a previously saved SAS program doesn't work. To open a previously saved program, open SAS and then choose File > Open. When accessing CQUEST remotely, the SAS Windowing Environment can be very slow so you may want to try batch mode.

7 Important First Step The version of SAS on CQUEST is 9.3. By default, this version of SAS uses ODS to save all graphs in graphics files (png) and output in an html file sashtml.htm. TURN THIS OFF. Command to do this is: Tools > Options > Preferences...

STA302/ SAS lecture8 Important First Step Continued Select: Create Listing

STA302/ SAS lecture9 SAS Help on CQUEST The SAS help is not completely installed on CQUEST. You may accidentally end up with this dialogue box. If you do, everything will stop until you click OK.

STA302/ SAS lecture10 How to Run a Program There are two ways to run a program in SAS… You can type your code in the program editor window, make this window your primary window (click on it) and then click on the running man or select Run and then Submit. The code will disappear. To get it back under Run select Recall last submit. Alternatively, you can write your SAS program in a text file and save it in your home directory. In the explorer window (in SAS) find the file under the directory you save it and double click on it. A new window with your text file will open. You can then highlight the code you wish to run and past it into the program editor window. Running a program writes output to a log window, an output window (if the program ran without errors) and sometimes graphic window. The SAS log window (or. log file) contain messages from SAS about your program written when you run it. Always check it for Errors.

STA302/ SAS lecture11 More on the SAS Windowing Environment To insert a line after the current line in the SAS program editor, type an i in the leftmost column over the first zero and hit enter. (For more tricks you can use in the SAS program editor, google “SAS Text Editor Line Commands".) Note that you need to save your program, your output, and your graphics files separately if you want to keep them.

STA302/ SAS lecture12 Running SAS Programs in Batch Mode Store your program in a (text) file called filename.sas and at a command prompt type sas filename. This creates filename.log and, if there were no errors in your program, filename.lst. If your data are in a separate file, you need to first save the data in a text file on your CQUEST account under the same directory where your program is stored. If you are using batch mode in an Xwindows terminal (Mac X11 or Xming), graphics will pop up in a new window on the screen. To save or print graphic plots, see the SAS code on slide 20 (or use ODS). If any of your SAS batch jobs have a problem and keep running, you must kill them. Type ps at a prompt tp get the number of the SAS job (the PID ), and then type kill -9 thePIDnumber to kill a job.

STA302/ SAS lecture 13 Basic of SAS Programming Every line ends with a semi-colon (;). SAS is not case sensitive; HadaS and hadas are the same withing a program. Anything between /* and */ is a comment. You can also comment out a single line by starting with a * but then it must end with a semi-colon. A typical SAS program has data steps (to create and manage your database) and procedures starting with the reserved word proc. The last line of the program should be run;. You can add titles to your output with the command title ‘This is my title’; at the beginning of your program or within any procedure. SAS has crazy ideas about line lengths. To fix this make options linesize = 79; the first line of your program. (There are many other options you can set, but this is the only one that is essential.) Every line ends with semi colon.

STA302/ SAS lecture14 The Data Step The code below create a dataset called snow. The data are read from the file gauge.txt. The data file is just a text file, with a new line for each observation. Because the first line of the data file contains the names of the variables and not data, we need to specify firstobs=2. data snow; infile ‘gauge.txt’ firstobs=2 ; input density gain; loggain=log(gain); run; If using MS Windows version of SAS at home, you will need to specify the entire file path to the data in your SAS program.

STA302/ SAS lecture15 More on the Data Step The code below creates a new dataset which starts with the data set snow but only includes observations for which the density is less than 0.6. data lesssnow; set snow; if density <0.6 ; To download a data file from the web onto your CQUEST account, right click and save (under This Frame if the data are within a frame). For more instructions on constructing and manipulating SAS datasets see the hand-out posted on the course webpage.

STA302/ SAS lecture16 Some SAS Procedures By default any procedure operates on the last dataset you created. To change this, add data = dataset_name on any proc line before the semi colon. Proc gplot - Graphic plots go into a graphic window (from which they can be printed or saved individually) or pop up in their own window if using batch mode in an Xwindow. For a variable1 versus variable2 scatterplot : Proc gplot; plot variable1*variable2;  Proc print ; print the contents of the last dataset. Useful to see if the data set have been correctly read into SAS.  Proc corr; prints summary statistics and pairwise correlations for all quantitative variables.

STA302/ SAS lecture17  Proc univariate plot; var variable_name; Gives many summary statistics and basic plots (or no plots if you leave out the word plot ). If you add the word normal SAS will do a few normality tests. The minimum commands for regression where variable1 is the independent variable and variable2 is the dependent variable: Proc reg; model variable2= variable1 ; Proc glm can also be used for regression but has fewer options.

STA302/ SAS lecture18 More on Proc Reg There are many more commands you can add to all procedures, but we will focus on proc reg. More will arise in class as needed but here are some commonly used plotting commands: proc reg simple; model y=x; plot y*x; /*scatterplot with fitted line*/ plot r.*x; /*plot of residuals vs x */ plot r.*p.; /*plot residuals vs predicted */ The keyword simple gives basic summary statistic for y and x. Variable names that end in a period are variables created by SAS.

STA302/ SAS lecture19 When ODS is on and no plot statements are given, proc reg produces some graphics files in your home directory (png format): DiagnosticsPanel.png, ResidualPlot.png (residuals versus explanatory variables), FitPlot.png (scatterplot, fitted line, and intervals around the line, for simple regression only).

STA302/ SAS lecture20 Saving Residuals and Predicted Values Saving residuals and predicted values to a dataset is useful if you want to do more analysis on the residuals or plot them. The following code creates a new dataset called outdata that includes all the variables in the original dataset plus variables called pred (the predicted values) and resid (the residuals). Proc reg; model variable2=variable1; output out=outdata p=pred r=resid;

STA302/ SAS lecture21 Saving Graphics Plots to a File In SAS window mode, make the graphic window your primary window, choose File from the toolbar and then to print select Print or to save select Export as Image. If you are working at home by using ssh to access CQUEST you will want to save graphic plots in files within the SAS program so that you can sftp them to your home computer or print them when you come to campus. The following commands save graphics plots in gif format to files in your home directory. filename grafout ‘.’; goptions device=gif gsfname=grafout; The files are named by the SAS procedure that created them. For example, if you have requested 3 plots within proc reg the plots will be stored in the files reg.gif, reg1.gif, and reg2.gif. Instead of gif you can specify jpeg and other image formats.

Example – Smoking and Cancer Data from 1970 from 25 occupational groups in England. Variables in this data set are: occupational group, smoking index and mortality index. The smoking index is the ratio of the average number of cigarettes smoked per day by men in the occupational group to the average number of cigarettes smoked per day by all men. The mortality index is the ratio of the rate of deaths from lung cancer among men in the particular occupational group to the rate of deaths from lung cancer among all men. For both indices, 100=average. STA302/ SAS lecture22

STA302/ SAS lecture23 Example – Smoking and Cancer Option ls=79; /* Data within program rather than in separate file*/ Data smoking; Input occupational_group $ smoking mortality; Datalines; Farmers_foresters_fisherman Miners_quarrymen Gas_coke_chemical_makers Glass_ceramics_makers ; Proc corr data = smoking; /*Change plotting symbol to a black dot*/ Symbol1 v=‘dot’;

STA302/ SAS lecture24 Proc gplot; plot mortality*smoking; Proc reg data = smoking; model mortality = smoking; plot mortality*smoking; plot r.*smoking; plot r.*p. Run; Note that there are no semi-colon after each of the data lines, but just one at the end. To save space for this example, I have left out most of the data. The full dataset is on the course website. Also, note that since occupational group is character data there is a $ after its name in the input statement.

STA302/ SAS lecture25 A Few Unix Commands These can be executed from a terminal window on the three Linux machines in RW211 or from home when accessing CQUEST through ssh. exit – Logs you off. Passwd – Change your password. Man command – Unix help for command ls – List the files in the current directory. mkdir directory_name – Make a new directory. cd directory_name – Changes directory to directory_name. cd – Changes to your home directory. less file_name – Display the content of file_name on your screen (q to quit). rm file_name – remove file_name. cp file_name1 file_name2 – Copies file_name1 to file_name2. mv file_name1 file_name2 – Moves (rename) file_name1 to file_name2.

STA302/ SAS lecture26 Editors: on the Linux machines in RW211, try gedit filename (the default editor). filename can be a new file. Gedit is available as Text Editor when you right-click on an existing file. If you are using ssh, try nano filename. A good Unix editor is vi but you need to learn about it before you use it. If you google “vi unix editor’ you will find some good tutorials.