DOC PREVIEW
Toronto STA 302 H1F - Introduction to SAS for Regression (onCQUEST)

This preview shows page 1-2-22-23 out of 23 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 23 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

STA 302 / 1001Introduction to SAS for Regression(on CQUEST)A.L. GibbsSeptember 20091Some Basics of CQUEST• The operating system in the RW labs (107/109 and 211) isWindows XP. There are a few terminals in RW 213 runningLinux. SAS is run from a Linux server. Your account is thesame and files are accessible in all labs / operating systems.• To logout:– Windows: look under Start– Linux: look under System• To open a web browser:– Windows: Firefox is an icon on your desktop.– Linux: Firefox is the mouse on a globe icon on the toolbar.• If backspace doesn’t work in SAS, turn off Num Lock.• Linux: If you want a terminal window you can either right clickon the desktop or click on Applications and then Accessories.2Using SAS: Batch vs Windows ModeSAS Windows Mode Pros:• Have access to SAS help.• Can avoid learning Unix commands.• Better control of graphics.SAS Windows Mode Cons:• SAS help isn’t great.• Have to purchase site license (or Xwindows software) or be inCQUEST lab.Note that SAS Windows mode is the same for both Windows andLinux operating systems on CQUEST.3Starting SAS Windows ModeWindows: Under Start choose Statistics Apps and then SAS.Linux: Under Applications choose CQUEST and then SAS or typesas at a command prompt in a terminal window.You will have to enter your CQUEST password. Many windowswill open including:• a program editor where you type your SAS program• a log window• an output window• an explorer for navigating through your windows and output(can ignore)• a graphics window will open once you’ve run a program thatproduces graphics plots4To insert a line after the current line in the CQUEST SAS programeditor, type an i in the leftmost column over the first zero and hitenter. For more tricks you can use in the SAS program editor,select Help, then Using this Window and click on SAS TextEditor Line Commands.To run a program: Make the program editor window your primarywindow (click on it) and click on the running man or select Run andthen Submit. Running a program writes output to a log window,an output window (if the program ran without errors) andsometimes a graphics window. Your code will also disappear. Toget it back under Run select Recall last submit.5Batch ModeUseful when working at home by using ssh to access CQUEST atlogin.cquest.utoronto.ca. Need to open a terminal window touse in a lab.Batch Mode Pros:• Accessible by using ssh to access CQUEST.Batch Mode Cons:• No access to SAS help files.• Need to know some Unix.6Running SAS Programs in Batch ModeStore your program in a (text) file calledfilename.sas and at a command prompt type sas filename.This creates filename.log and, if your run was successful,filename.lst. If your data are in a separate file, you need to firstsave the data in a text file on your CQUEST account.If you are using batch mode in an Xwindows terminal, graphics willpop up in a new window on the screen. To save (or print) graphicsplots, see the SAS code on slide 19.Note also that to print files on CQUEST at home you will have tofirst 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 to get the number of theSAS job (the PID), and then type kill -9 thePIDnumber to kill ajob.)7SAS Log Window (or .log file)Messages from SAS about your program written when you run it.Always check for ERRORs.8Basics of SAS Programming• Every line ends with a semi-colon.• SAS is not case sensitive; ALisoN and alison are the samewithin a program.• Every line ends with a semi-colon.• Anything between /* and */ is a comment.• You can also comment out a single line by starting with a * butthen it must end with a semi-colon.• A typical SAS program has data steps (to create and manageyour datasets) and procedures starting with the reserved wordproc.9• The last line of the program should be run;.• You can add titles to your output with the commandtitle ‘This is my title’;at the beginning of your program or within any procedure.• SAS has crazy ideas about line lengths. To fix this makeoptions linesize=79;the first line of your program. (There are many other optionsyou can set, but this is the only one that is essential.)• Every line ends with a semi-colon.10The Data StepThe code below creates a dataset called to1993.data to1993;infile ‘maunaloadata.txt’ firstobs=33;input year 1-4 month 6-7 day 9-10 time1 $ date $time2 $ cfc11 nd sd f cs rem;if cfc11 < -9999 then cfc11=.;time=year+(month-1)/12;drop day time1 date time2 nd sd f cs rem;The data are read from the file maunaloadata.txt.The data file is a text file, with a new line for each observation.Because the first 33 lines of this file contains information and notdata, we need to specify firstobs=33.Because the dates are in the form 1993-01-01, we specified thecolumns of the data file that contain the year, month, and day.11The rest of the variables in the datafile are delimited by spaces.A $ after a variable name on the input line indicates that thevariable is character (rather than numeric) data. (I did that heresince the times and dates contain special characters, but I don’tcare about the information in the data file for time, date, andtime2.)The missing data code in SAS is . (a period). Values of cfc11 lessthan −9999 were replaced with the missing value code.The variables that were read in from the data file but that we willnot be using were dropped from the dataset.A new variable, time, was created from year and month.12More on the Data StepThe code below creates a new dataset which starts with the datasetto1993 but only includes observations for which the time is before1990.data preMP;set to1993;if time < 1990;The following code concatenates the two datasets. The datalinesfrom after1994 are appended to the datalines from to1993 in thenew dataset all. If a variable exists in one of the datasets and notin the other, it is created and given missing values for the otherdataset.data all;set to1993 after1994;13Store all of your files in your home directory.To download a data file from the web onto your CQUEST account,right click and save (under This Frame if the data are within aframe).If using the MSWindows version of SAS at home, you will need tospecify the entire file path to the data in your SAS program.14Some SAS ProceduresBy default any procedure operates on the last dataset you created.To change this, add data=datasetname on any proc line before


View Full Document

Toronto STA 302 H1F - Introduction to SAS for Regression (onCQUEST)

Download Introduction to SAS for Regression (onCQUEST)
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to SAS for Regression (onCQUEST) and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to SAS for Regression (onCQUEST) 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?