

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Applied Linear Regression, 22S:
Instructor: Cowles
Lab 1 Sep. 4, 2002
If you want SAS for your own computer
Getting started in the ITC
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”
Other useful features on the course web page
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
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 ;
infile ’c:\temp\OECD.dat’ ;
input name $13. pcgdp pch beds los docs infmort ;
run ;
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 ;
run ;
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 ;
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 ;
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