Docsity

Prof. Cowles - Applied Linear Regression | 22S 152, Lab Reports of Statistics

Toggle sidebar
bg1
Applied Linear Regression, 22S:152
Instructor: Cowles
Lab 1
Sep. 4, 2002
1If you want SAS for your own computer
SAS for Students, Windows version, is available at the IMU Bookstore at a reduced cost
for students using the software for academic purposes. This license needs to be renewed in
October. See the SAS Information page,
http://www.its.uiowa.edu/its/cs/software/sas.html
for product information.
2Getting started in the ITC
ITC computers will display a login screen. Users should enter their HawkID and password
in the spots provided. Students can find their HawkID and default passwords on the ISIS
system.
3Downloading files from the course web page
Double click on Netscape. Enter the address of the my web page in the location box at the
top of the screen.
www.stat.uiowa.edu/~kcowles
Then click on “Course homepages” and “22S:152”
Click on “Datasets,” and when the next screen appears, click on the underlined link
“Datasets.” Three types of files may be accessed:
•Files ending in .dat are data files for your use with the software package SAS.
•Files ending in .info contain descriptive information about datasets.
•Files ending in .txt are datasets for use in a different class with a different software
package.
To download a data file for use in this lab:
•Right click the file name (use the right, not left, mouse button)
•In the dialog box that opens, left click “Save link as” (use the left mouse button)
•In the “save as” dialog box move to the “temp” directory on the C: drive and click
“Save.”
1
•(If you preferred to save the file on your own disk in drive A: so that you could use
it on a different computer later, you would move to drive A: in the dialog box before
saving.)
Left click the “OECD.info” file to read a description of the “OECD” dataset. (Note that the
system on which I stored these files alphabetizes upper case letters before lower case letters.)
Click “Back” to get back to the list of datasets. Then download the file “OECD.dat”
according to the directions above.
4Other useful features on the course web page
Return to the main course web page andclick “Web resources.” Note that there is a directory
of the locations and hours of all the campus ITCs, as well as links to other useful sites.
Lecture notes, homework assignments, and lab handouts are posted under “Handouts.”
These are in PDF format, which may be read and printed in the ITCs and on most other
computers. (Acrobat Reader, the software that reads and prints PDF files, can be down-
loaded for free.)
5Accessing SAS
Double click on SAS 8.2e.
You will get a screen that shows:
•a menu bar
•a log window
•a program editor window
6Entering commands and programs
Click in the program editor window. You may now type commands and programs in this
window.
7How SAS programs and commands are organized
Use a DATA step to organize your data by creating a SAS dataset. Then use PROC steps
to analyze your data using SAS procedures. Once you have created a SAS dataset, you may
apply any SAS procedures to it without recreating the dataset.
DATA and PROC steps consist of SAS statements. Each statement must end with a semi-
colon. Most statements include one or more keywords that must be spelled exactly as
shown.
2
pf3

Partial preview of the text

Download Prof. Cowles - Applied Linear Regression | 22S 152 and more Lab Reports Statistics in PDF only on Docsity!

Applied Linear Regression, 22S:

Instructor: Cowles

Lab 1 Sep. 4, 2002

If you want SAS for your own computer

SAS for Students, Windows version, is available at the IMU Bookstore at a reduced costfor students using the software for academic purposes. This license needs to be renewed inOctober. See the SAS Information page, http://www.its.uiowa.edu/its/cs/software/sas.html for product information. 2

Getting started in the ITC

ITC computers will display a login screen. Users should enter their HawkID and passwordin the spots provided. Students can find their HawkID and default passwords on the ISISsystem. 3

Downloading files from the course web page Double click on Netscape. Enter the address of the my web page in the location box at thetop of the screen.

www.stat.uiowa.edu/~kcowles Then click on “Course homepages” and “22S:152”Click on “Datasets,” and when the next screen appears, click on the underlined link“Datasets.” Three types of files may be accessed:

-^ Files ending in .dat are data files for your use with the software package SAS. •^ Files ending in .info contain descriptive information about datasets. •^ Files ending in .txt are datasets for use in a different class with a different softwarepackage. To download a data file for use in this lab: -^ Right click the file name (use the

right

, not left, mouse button)

-^ In the dialog box that opens, left click “Save link as” (use the

left

mouse button)

-^ In the “save as” dialog box move to the “temp” directory on the C: drive and click“Save.”

-^ (If you preferred to save the file on your own disk in drive A: so that you could useit on a different computer later, you would move to drive A: in the dialog box beforesaving.) Left click the “OECD.info” file to read a description of the “OECD” dataset. (Note that thesystem on which I stored these files alphabetizes upper case letters before lower case letters.)Click “Back” to get back to the list of datasets.

Then download the file “OECD.dat”

according to the directions above. 4

Other useful features on the course web page

Return to the main course web page and click “Web resources.” Note that there is a directoryof the locations and hours of all the campus ITCs, as well as links to other useful sites.Lecture notes, homework assignments, and lab handouts are posted under “Handouts.”These are in PDF format, which may be read and printed in the ITCs and on most othercomputers. (Acrobat Reader, the software that reads and prints PDF files, can be down-loaded for free.) 5

Accessing SAS Double click on SAS 8.2e.You will get a screen that shows:

-^ a menu bar •^ a log window •^ a program editor window

Entering commands and programs

Click in the program editor window. You may now type commands and programs in thiswindow. 7

How SAS programs and commands are organized Use a

DATA step

to organize your data by creating a SAS dataset. Then use

PROC steps

to analyze your data using SAS procedures. Once you have created a SAS dataset, you mayapply any SAS procedures to it without recreating the dataset.DATA and PROC steps consist of SAS

statements

. Each statement must end with a semi-

colon.

Most statements include one or more

keywords

that must be spelled exactly as

shown.

The DATA step: Creating a SAS dataset Before it can process data, SAS must read in the data in the form of a table with

-^ a row for each

observation

-^ a column for each

variable

You must choose a name for the entire dataset and a name for each variable. SAS has thefollowing rules for names:

-^ SAS names must begin with a letter or an underscore. The remaining characters ina SAS name can be letters, numbers, or underscores.

There must be no embedded

blanks. SAS distinguishes between two types of variables:

-^ numeric variables

, which contain only digits, decimal points, and minus signs, and

with which arithmetic operations may be done • character variables

(all other kinds of data)

Reading data in from an existing datafile You have saved the file “OECD.dat” in the “temp” directory. Use an “infile” statement totell SAS to use it. data OECD ;

  • gives dataset a name for SAS ;

infile ’c:\temp\OECD.dat’ ;

  • tells SAS where the data is ;

input name $13. pcgdp pch beds los docs infmort ;

  • $13 after name identifies character vbl* and tells SAS maximum length of values ;

run ;

  • end of data step ;

Type these lines into the program editor window. (You do not have to type the asterisksand comments after them.) To make SAS run these statements and create the dataset, usethe mouse to highlight the block of statements and then click on the icon of the runningman.SAS will use the log window to tell you what it has done. Be sure to check the log windowfor any error messages.

If any errors are reported, click in the program editor window to

make it active. Correct the errors in the code and then rerun the block of code.Now we can apply any SAS procedures to this dataset, either by typing in additional codein the “Program Editor” window or by using one of the menu-driven tools.

Displaying the dataset

First we will use

proc print

to list the entire dataset on the screen. Displaying all or part

of the dataset is always wise in order to make sure that you have read the data in correctly. proc print data = OECD ;

  • word after "data = " must be the name of* a SAS dataset created in a data step ;

run ;

  • end of print procedure ;

You can restrict how many records are displayed as follows: proc print data = OECD (obs = 10) ;run ; You can also use the

var

statement to restrict which variables are displayed:

proc print data = OECD ;var name pcgdp infmort ;

  • variable names must be from the data step in* which the dataset was created or modified;

run ; 11

Proc univariate for summary statistics of quantitative variables Proc univariate

is a quick and convenient way to get a complete numeric summary of the

distribution of a quantitative variable. You can also request plots (which are ugly but easyto print). proc univariate plot data = OECD ;

  • leave out word "plot" if you dont’t* want or need the plots ;

var pcgdp infmort ;run ; 12

Interactive data description with “Insight” We will use “Insight” to get additional descriptive statistics and plots regarding these data.From the menu bar, select the following sequence of choices:

-^ Solutions -^ Analysis

∗^ Interactive data analysis

In the window that appears, you must specify which dataset you wish to use.

Do so by

clicking

-^ Library: Work