Toronto STA 302 H1F - A Step by Step Guide to Learning SAS

Unformatted text preview:

A Step by Step Guide toLearning SASObjectiveLECTURE OUTLINEGetting Started with SAS1.1.1Pros and Cons1.1.1cont’d…1.1.2Windows1.1.3Batch Mode1.2SAS Help1.3SAS RunElements of the SAS Software2.1SAS Program Editor2.2Log and Output Windows2.3Other SAS WindowsBasics of SAS Programming3.1Essentialsof SAS Programming3.1cont’d…3.2Extra Essentialsof SAS Programming3.2cont’d…3.2 cont’d…4.Data Step4.1What is a Data Step?4.2Ingredients of a Data Step4.2 cont’d…4.3What can you do within it?4.4.1Basic Example of a Data Step4.4.2Manipulating the Existing Data4.4.3Designating a Character Variable4.4.4Data from an External File4.5What can you do with it?4.5 cont’d…4.6 Some Comments5.Regression Analysis5.1Proc Reg5.2Ingredients of Proc Reg5.2 cont’d…5.2 cont’d… options5.2 cont’d… more options5.3What does it do?5.4What else can you do with it?5.4 cont’d… plot options5.5An Example5.6OutputAnalysis – some questionsMore questions….Now you can….6. Hints and TidbitsLast Comments & ContactReferences1A Step by Step Guide toLearning SASThe Fundamentals of SAS Programming and an Introduction to Simple Linear Regression ModelsSeptember 29th, 2003Anjali Mazumder2Objective• Familiarize yourselves with the SAS programming environment and language.• Learn how to create and manipulate data sets in SAS and how to use existing data sets outside of SAS.• Learn how to conduct a regression analysis.• Learn how to create simple plots to illustrate relationships.3LECTURE OUTLINE• Getting Started with SAS• Elements of the SAS program• Basics of SAS programming• Data Step• Proc Reg and Proc Plot• Example• Tidbits• Questions/Comments4Getting Started with SAS1.1 Windows or Batch Mode?1.1.1 Pros and Cons1.1.2 Windows1.1.3 Batch ModeReference:www.cquest.utoronto.ca/stats/sta332s/sas.html51.1.1 Pros and ConsWindows:Pros:• SAS online help available. • You can avoid learning any Unix commands. • Many people like to point and click. Cons:• SAS online help is incredibly annoying. • Possibly very difficult to use outside CQUEST lab. • Number of windows can be hard to manage.61.1.1 cont’d…Batch Mode:Pros:• Easily usable outside CQUEST labs. • Simpler to use if you are already familiar with Unix. • Established Unix programs perform most tasks better than SAS's builtin utilities. Cons:• Can't access SAS's online help. • Requires some basic knowledge of Unix.71.1.2 Windows• You can get started using either of these two ways:1. Click on Programsat the top left of the screen and select CQUEST_APPLICATIONSand then sas.2. In a terminal window type: sasA bunch of windows will appear –don’t get scared!81.1.3 Batch Mode• First, make sure you have set up your account so you can use batch mode.• Second, you need to create a SAS program.• Then ask SAS to run your program (foo) using the command:sas foo or sas foo.sasEither way, SAS will create files with the same name as your program with respective extensions for a log and output file (if there were no fatal errors).91.2 SAS Help• If you are running SAS in a window environment then there is a online SAS available. • How is it helpful?You may want more information about a command or some other aspect of SAS then what you remember from today or that is in this guide.• How to access SAS Help?1. Click on the Help button in task bar.2. Use the menu command – Online documentation• There are three tabs: Contents, Index and Find101.3 SAS Run• If you are running SAS in a window environment then simply click on the Run Icon. It’s the icon with a picture of a person running!• For Batch mode, simply type the command: filename.sas11Elements of the SAS Software2.1 SAS Program Editor: Enhanced Editor2.2 Important SAS Windows: Log and Output Windows2.3 Other SAS Windows: Explorer and Results Windows122.1 SAS Program Editor • What is the Enhanced Editor Window?This is where you write your SAS programs. It will contain all the commands to run your program correctly.• What should be in it?All the essentials to SAS programming such as the information on your data and the required steps to conduct your analysis as well as any comments or titles should be written in this window (for a single problem). See Section 3-6.• Where should I store the files?In your home directory. SAS will read and save files directly from there.132.2 Log and Output Windows• How do you know whether your program is syntactically correct?Check the Log window every time you run a program to check that your program ran correctly – at least syntactically. It will indicate errors and also provide you with the run time.• You ran your program but where’s your output?There is an output window which uses the extension .lst to save the file.If something went seriously wrong – evidence will appear in either or both of these windows.142.3 Other SAS Windows• There are two other windows that SAS executes when you start it up: Results and Explorer Windows• Both of these can be used as data/file management tools.• The Results Window helps to manage the contents of the output window.• The SAS Explorer is a kind of directory navigation tool. (Useful for heavy SAS users).15Basics of SAS Programming3.1 Essentials3.1.1 A program!3.1.2 End of a command line/statement3.1.3 Run Statement3.2 Extra Essentials3.2.1 Comments3.2.2 Title3.2.3 Options3.2.4 Case (in)sensitivity163.1 Essentialsof SAS Programming3.1.1 Program• You need a program containing some SAS statements. • It should contain one or more of the following:1) data step: consists of statements that create a data set2) proc step: used to analyze the data173.1 cont’d…3.1.2 End of a command line or statement• Every statement requires a semi-colon (;) and hit enter afterwards. Each statement should be on a new line.• This is a very common mistake in SAS programming –so check very carefully to see that you have placed a ; at the end of each statement.3.1.3 Run command or keyword• In order to run the SAS program, type the command: run; at the end of the last data or proc step. • You still need to click on the running man in order to process the whole program.183.2 Extra Essentialsof SAS Programming3.2.1 Comments• In order to put comments in your SAS program (which are words used to explain what the program is doing but not which SAS is to execute as commands), use /*to start a comment and */to end a comment. For example, /* My SAS


View Full Document

Toronto STA 302 H1F - A Step by Step Guide to Learning SAS

Download A Step by Step Guide to Learning SAS
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 A Step by Step Guide to Learning SAS 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 A Step by Step Guide to Learning SAS 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?