QUICK-START GUIDE TO USING THE SAS SYSTEM FOR WINDOWS
AT JAMES MADISON UNIVERSITY

1. Make up your mind that you’re going to have every character, every comma and every period right in your files before you try to run them using the SAS statistical analysis system. Don’t even think of blaming SAS for being wrong. It isn’t.

2. Go to a computer lab that has SAS (see https://remedy.jmu.edu/labs/onesoft.asp?softname=SAS). This includes the Zane Showker Hall lab and several others. You’ll be using Microsoft Excel and The SAS System for Windows.

3. First, open Excel. Enter in the following data in the first three columns of a new worksheet:

M / F / C
200909 / 70 / 21.111
200910 / 34 / 1.111
200911 / 56 / 13.333
200912 / 45 / 7.222
201001 / 49 / 9.444


Next, highlight everything you just typed in (from M in the upper left to 9.444 in the lower right), then right-click, choose Define Name, and enter the name data. That’s right, just call that table “data.”

Now save the file as Book1.xls in a convenient disk location – for example, e:\Book1.xls on a flash drive.

4. Make sure you have exited from Excel first and now launch SAS. From the Start menu, choose All Programs, SAS, and SAS 9 (English). You’ll see several SAS windows open at once.

Now in the Editor window, copy and paste the following commands. These commands will instruct SAS where to find your data and how to read it in.

PROC IMPORT OUT= WORK.yourusername

DATAFILE= "E:\Book1.xls"

DBMS=EXCEL REPLACE;

RANGE="data";

GETNAMES=YES;

MIXED=NO;

SCANTEXT=YES;

USEDATE=YES;

SCANTIME=YES;

RUN;

Next, immediately after SCANTIME=YES; type the following commands:

PROC PRINT;
RUN;

PROC REG;
TITLE "Fahrenheit and Celsius temperatures observed";
MODEL F = C;
RUN;


Get every character and bit of punctuation right. End every command line with a semi-colon.
Note: SAS does not like curly quotes like these: “ ”. If they somehow get into your program, replace them with straight quotes like these: " ".
Now save your command file as PROB1.SAS somewhere that you can find it again if necessary.

5. Notice that you haven’t run any statistics yet in SAS; you have just created a script (the SAS command file). Now to run the statistics, look at the top toolbar of the SAS screen and locate a button with a picture of a little person running. This is the “Submit” button. Click it once and your program will run.

6. If your program was unsuccessful, the Log window (labeled Log-Untitled at first) will contain a description of errors you need to correct. Make changes in the Editor window and try running the program again. If you have multiple runs, your log file will get cluttered. You can clear out the log window by clicking in it, then choosing Edit, Clear All from the menu.

7. When your program successfully runs, the Output window pops up and shows you your statistical results. To print this output, use File Print.

8. It’s important on every assignment to check each Output file for obvious mistakes. Here are three ways to check:

·  Check the results of PROC PRINT; to see if SAS was successful in reading in the data you thought were being read in. In this case, it’s five observations on the variables F and C.

·  Check the Dependent Mean figure to see if it equals the mean of the dependent variable (the first variable mentioned in the MODEL statement). In this case, it’s 50.8. If you get a different value for Dependent Mean, there’s a mistake.

·  Look at the printout to find the number of observations SAS used and make sure it equals the total number of observations in your data set. Data handling errors can cause entire lines of data to be dropped.

9. To get a feel for how sensitive SAS is to correct order, punctuation, and the like:

·  Report what happens if you run PROB1.SAS with all lines correct except that the semi-colon after PROC REG; is omitted.

·  Report what happens if you run PROB1.SAS with all lines correct except that the statement MODEL F = C is moved to occur immediately after the SCANTIME=YES; statement.

·  Report what happens if you do everything else right, but incorrectly specify the data file as Book01.xls instead of Book1.xls.

10. Resolve that you will read and study through the JMU SAS guide located on the class website. Also promise yourself that you’ll check the printed data, Dependent Mean and number of observations on every assignment that uses SAS -- you’ll be glad you did!

(What you have just worked through is only a quick start guide and does not take the place of a SAS reference. The JMU SAS guide for Econ 385 is on the class website. Also note: For simplicity, this quick-start guide does not include many shortcuts that you can find and use if you explore SAS references.)

Commented text of simple test file

PROC IMPORT OUT= WORK.yourusername
DATAFILE= “E:\Book1.xls”
DBMS=EXCEL REPLACE;
RANGE=“data”;
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES; / * Sets up working data set
* Specifies file location
* Tells SAS how to handle Excel file
* Reads only from the “data” table
* Gets variable names from first row
* Assumes all variables are numbers
* Sets column width using text labels
* Specifies handling of date data
* Looks for date data
PROC PRINT
RUN; / * Tells SAS to “print” the data to your screen; does not send to printer
TITLE ‘Fahrenheit and Celsius temperatures observed’; / * Assigns a title to the next section
MODEL F = C; /
* Specifies an equation with F and C as variables
RUN; /
* Tells SAS to go on and run the model


Some notes on best practices in data handling:

If you get sloppy with data, you will make mistakes. Accordingly, in this class there are potentially two penalties for bad data handling practices: small penalties when you commit them and, potentially, the major penalties that occur when you get the wrong answers as a result.

Here are some aspects of best practices in data handling:

1.  You name all files properly. For example, the data for Assignment 1 is in Book1.xls. If for Assignment 2 you simply reuse the program, calling that data file “Book1.xls” and putting in Assignment 2’s data, that is a bad data handling practice.

2.  In a similar manner, you make all applicable substitutions from examples. In the example above, one statement says
PROC IMPORT OUT= WORK.yourusername.
If you leave that just as it is instead of substituting your own username, such as smith9jj, you are using bad data handling practice. Throughout the field of econometrics, there are multiple opportunities to slack off, using example code or language without properly adapting it. Avoid this particular kind of slacking off, as it sends a strong message that you are lazy or even dishonest.

3.  When you use SAS to do econometrics, data files and program files are kept separate. You make the data file correct and then do as little as possible to it. For example, if you want to multiply a variable by 100, you do not use Excel to do that. You import the unaltered data file and multiply by 100 in SAS.

4.  Data files are fully documented with sources and definitions. This documentation can really mess up SAS if it reads those words in, trying to make them into data observations. Therefore you carefully label the data section with the table name “data,” and use PROC IMPORT to read in only the “data” – and not all those sources and definitions. But do not omit those sources and definitions from the data file.

5.  More often that you’d think, people who do data analysis have to go back and figure out what they did, weeks or even years later. Therefore it is important to fully document data sources and program files, and to keep them where they can be found. One good tip is to get a Gmail account and then email those files to yourself with lots of key words that would turn up in a later search. For example, the subject of such an email might be: “Data and program files for Fisher equation project inflation interest rates.”

6.  The lines from PROC IMPORT to SCANTIME=YES; are difficult and important. You have to get them exactly right. SAS automates this procedure with the Import Data wizard, if you care to use it. To start, choose File | Import Data. Search for online help if you need assistance with the wizard.

7.  Use your head. This comes up over and over. Here’s an example: If your flash drive shows up as something other than “E:\” on a given computer, use that letter instead of E. Here’s another: Depending on your Excel setup, you may find it more convenient to save Excel files as *.xlsx (with the added “x”). But do remember that “x” for later work if it is there.