SAS Data Statement Example Problem

Overview

This is an example problem in using the concepts we learned about the data step. Hopefully this will clear up any misconceptions you have in using the data step.

Example Problem

We want to create a SAS program named example1.sas and a data file named example1.dat.

Problem Definition

We have a data file that has 3 variables CASEID, MATHSAT, SCORE. Where:
CASEID - unique identifier for a subject
MATHSAT - SAT score on Mathematics subject area
SCORE - Calculus average at the end of the semester.

We will ultimately want to analyze the relation of MATHSAT and final calculus SCORE. There are 10 cases to be entered which are listed below in the variable order of CASEID, MATHSAT, SCORE. Enter the data as shown into a file named example1.dat.

0001 650 75
0002 625 80
0003 700 85
0004 550 74
0005 800 92
0006 500 68
0007 725 75
0008 675 88
0009 600 81
0010 700 90

Create a SAS program that includes the following:

  1. A title identifying your program
  2. Set the linewidth on output to be 80
  3. Create a data set named sample1
  4. Create your input statement
  5. Read the data from the file.
  6. Define labels for each variable giving it a descriptive name.
  7. Print out the values in the dataset you created.
  8. Print off the log file and listing file.

If you have problems, here are my files to look at:

  • example1.sas
  • example1.dat
  • example1.lst
  • example1.log
    Author - Jack Suess
    UMBC University Computing Services
    Created - 1/15/96