Some Basics of CQUEST

Similar documents
(on CQUEST) A.L. Gibbs

(on CQUEST) A.L. Gibbs

STA 303 / 1002 Using SAS on CQUEST

INTRODUCTION TO SAS STAT 525 FALL 2013

ST Lab 1 - The basics of SAS

A Step by Step Guide to Learning SAS

CS Fundamentals of Programming II Fall Very Basic UNIX

STAT:5400 Computing in Statistics

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Parallel Programming Pre-Assignment. Setting up the Software Environment

Stat 5411 Lab 1 Fall Assignment: Turn in copies of bike.sas and bike.lst from your SAS run. Turn this in next Friday with your assignment.

Tiny Instruction Manual for the Undergraduate Mathematics Unix Laboratory

Running Sentaurus on the DOE Network

Session 1: Accessing MUGrid and Command Line Basics

You can use the WinSCP program to load or copy (FTP) files from your computer onto the Codd server.

Linux hep.wisc.edu

SAS Training Spring 2006

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

When you first log in, you will be placed in your home directory. To see what this directory is named, type:

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C

Unix Tutorial Haverford Astronomy 2014/2015

CSE 391 Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

Part I. Introduction to Linux

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

CSE 390a Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

EKT332 COMPUTER NETWORK

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Lecture # 2 Introduction to UNIX (Part 2)

STA 248 S: Some R Basics

Using the Zoo Workstations

Getting Started With UNIX Lab Exercises

Getting Started with UNIX

CSCI 161: Introduction to Programming I Lab 1a: Programming Environment: Linux and Eclipse

For Dr Landau s PHYS8602 course

Introduction. Overview of 201 Lab and Linux Tutorials. Stef Nychka. September 10, Department of Computing Science University of Alberta

Introduction to the Linux Command Line

STAT 7000: Experimental Statistics I

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.)

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Introduction to Linux and Supercomputers

Tutorial 1: Unix Basics

Firewalls can prevent access to the Unix Servers. Please make sure any firewall software or hardware allows access through Port 22.

User Guide Version 2.0

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

Lab Working with Linux Command Line

Linux Survival Guide

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

Oxford University Computing Services. Getting Started with Unix

Linux/Cygwin Practice Computer Architecture

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

Working with Basic Linux. Daniel Balagué

CS370 Operating Systems

JCCC Virtual Labs. Click the link for more information on installing on that device type. Windows PC/laptop Apple imac or MacBook ipad Android Linux

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

Epidemiology Principles of Biostatistics Chapter 3. Introduction to SAS. John Koval

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

Unix Workshop Aug 2014

Logging in to the CRAY

Getting started with Hugs on Linux

commands exercises Linux System Administration and IP Services AfNOG 2015 Linux Commands # Notes

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction to the UNIX command line

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Linux Bootcamp Fall 2015

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

Lab Assignment #1. University of Pittsburgh Department of Electrical and Computer Engineering

CSC 112 Lab 1: Introduction to Unix and C++ Fall 2009

Helpful Tips for Labs. CS140, Spring 2015

Editors in Unix come in two general flavours:

CS CS Tutorial 2 2 Winter 2018

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

An Introductory Tutorial on UNIX

The Directory Structure

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Chapter-3. Introduction to Unix: Fundamental Commands

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Introduction to Linux

CSE115 Lab exercises for week 1 of recitations Spring 2011

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

APP-J: WHAT IS APPLICATION JUKEBOX?

Applied Regression Modeling: A Business Approach

Network Monitoring & Management. A few Linux basics

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Linux Command Line Primer. By: Scott Marshall

Linux Exercise. pwd answer: We call this directory (into which you get when you log in) your home directory.

Using WestGrid from the desktop Oct on Access Grid

Starting SAS. 2. Click START, ALL PROGRAMS, SAS, and the SAS ICON

In this exercise you will practice working with HDFS, the Hadoop. You will use the HDFS command line tool and the Hue File Browser

Chap2: Operating-System Structures

BE CAREFUL! The Summer Research Student s Guide to UNIX

Department of Computer Science University of Pretoria. Introduction to Computer Science COS 151

AMS 200: Working on Linux/Unix Machines

MTU Computer Structure

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

You should see something like this, called the prompt :

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

commandname flags arguments

Transcription:

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/1001 - SAS lecture 1

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/1001 - SAS lecture 2

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 STA302/1001 - SAS lecture 3

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/1001 - SAS lecture 4

Batch Mode Batch mode is useful when working at home by using ssh to access CQUEST at login.cquest.utoronto.ca. To use batch mode in a lab you need to open a terminal window. Using batch mode require to know some Unix. There is no access to SAS help files when using batch mode. STA302/1001 - SAS lecture 5

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, graphics will pop up in a new window on the screen. To save or print graphic plots, see the SAS code on slide 14. Note also, that to print files on CQUEST at home you will have to first sftp them to your home computer. 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/1001 - SAS lecture 6

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/1001 - SAS lecture 7

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/1001 - SAS lecture 8

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/1001 - SAS lecture 9

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/1001 - SAS lecture 10

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/1001 - SAS lecture 11

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. Note that the plots produce within proc reg are graphics plots. To produce non-graphics plots; add the keyword lineprinter on the proc reg line. Variable names that end in a period are variables created by SAS. STA302/1001 - SAS lecture 12

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/1001 - SAS lecture 13

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. STA302/1001 - SAS lecture 14

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/1001 - SAS lecture 15

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 77 84 Miners_quarrymen 137 116 Gas_coke_chemical_makers 117 123 Glass_ceramics_makers 94 128 ; Proc corr data = smoking; /*Change plotting symbol to a black dot*/ Symbol1 v= dot ; STA302/1001 - SAS lecture 16

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/1001 - SAS lecture 17

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/1001 - SAS lecture 18

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 pico 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. STA302/1001 - SAS lecture 19