Previous Page | Next Page

What Is the SAS System?

Components of Base SAS Software

Overview of Base SAS Software

Base SAS software contains the following:

Learning to use Base SAS enables you to work with these features of SAS. It also prepares you to learn other SAS products, because all SAS products follow the same basic rules.

Data Management Facility

SAS organizes data into a rectangular form or table that is called a SAS data set. The following figure shows a SAS data set. The data describes participants in a 16-week weight program at a health and fitness club. The data for each participant includes an identification number, name, team name, and weight (in U.S. pounds) at the beginning and end of the program.

Rectangular Form of a SAS Data Set

[Rectangular Form of a SAS Data Set]

In a SAS data set, each row represents information about an individual entity and is called an observation. Each column represents the same type of information and is called a variable. Each separate piece of information is a data value. In a SAS data set, an observation contains all the data values for an entity; a variable contains the same type of data value for all entities.

To build a SAS data set with Base SAS, you write a program that uses statements in the SAS programming language. A SAS program that begins with a DATA statement and typically creates a SAS data set or a report is called a DATA step.

The following SAS program creates a SAS data set named WEIGHT_CLUB from the health club data:

data weight_club; 1 
   input IdNumber 1-4 Name $ 6-24 Team $ StartWeight EndWeight; 2 
   Loss=StartWeight-EndWeight; 3 
   datalines; 4 
1023 David Shaw          red 189 165 5 
1049 Amelia Serrano      yellow 145 124 5 
1219 Alan Nance          red 210 192 5 
1246 Ravi Sinha          yellow 194 177 5 
1078 Ashley McKnight     red 127 118 5 
; 6 


The following list corresponds to the numbered items in the preceding program:

[1] The DATA statement tells SAS to begin building a SAS data set named WEIGHT_CLUB.

[2] The INPUT statement identifies the fields to be read from the input data and names the SAS variables to be created from them (IdNumber, Name, Team, StartWeight, and EndWeight).

[3] The third statement is an assignment statement. It calculates the weight each person lost and assigns the result to a new variable, Loss.

[4] The DATALINES statement indicates that data lines follow.

[5] The data lines follow the DATALINES statement. This approach to processing raw data is useful when you have only a few lines of data. (Later sections show ways to access larger amounts of data that are stored in files.)

[6] The semicolon signals the end of the raw data, and is a step boundary. It tells SAS that the preceding statements are ready for execution.

Note:   By default, the data set WEIGHT_CLUB is temporary; that is, it exists only for the current job or session. For information about how to create a permanent SAS data set, see Introduction to DATA Step Processing.   [cautionend]

Programming Language

Elements of the SAS Language

The statements that created the data set WEIGHT_CLUB are part of the SAS programming language. The SAS language contains statements, expressions, functions and CALL routines, options, formats, and informats - elements that many programming languages share. However, the way you use the elements of the SAS language depends on certain programming rules. The most important rules are listed in the next two sections.

Rules for SAS Statements

The conventions that are shown in the programs in this documentation, such as indenting of subordinate statements, extra spacing, and blank lines, are for the purpose of clarity and ease of use. They are not required by SAS. There are only a few rules for writing SAS statements:

Rules for Most SAS Names

SAS names are used for SAS data set names, variable names, and other items. The following rules apply:

Special Rules for Variable Names

For variable names only, SAS remembers the combination of uppercase and lowercase letters that you use when you create the variable name. Internally, the case of letters does not matter. "CAT," "cat," and "Cat" all represent the same variable. But for presentation purposes, SAS remembers the initial case of each letter and uses it to represent the variable name when printing it.

Data Analysis and Reporting Utilities

The SAS programming language is both powerful and flexible. You can program any number of analyses and reports with it. SAS can also simplify programming for you with its library of built-in programs known as SAS procedures. SAS procedures use data values from SAS data sets to produce preprogrammed reports, requiring minimal effort from you.

For example, the following SAS program produces a report that displays the values of the variables in the SAS data set WEIGHT_CLUB. Weight values are presented in U.S. pounds.

options linesize=80 pagesize=60 pageno=1 nodate; 

proc print data=weight_club;
   title 'Health Club Data';

This procedure, known as the PRINT procedure, displays the variables in a simple, organized form. The following output shows the results:

Displaying the Values in a SAS Data Set

                                Health Club Data                               1

              Id                                    Start      End
     Obs    Number    Name               Team      Weight    Weight    Loss

      1      1023     David Shaw         red         189       165      24 
      2      1049     Amelia Serrano     yellow      145       124      21 
      3      1219     Alan Nance         red         210       192      18 
      4      1246     Ravi Sinha         yellow      194       177      17 
      5      1078     Ashley McKnight    red         127       118       9 
To produce a table showing mean starting weight, ending weight, and weight loss for each team, use the TABULATE procedure.
options linesize=80 pagesize=60 pageno=1 nodate; 

proc tabulate data=weight_club; 
   class team;
   var StartWeight EndWeight Loss;
   table team, mean*(StartWeight EndWeight Loss); 
   title 'Mean Starting Weight, Ending Weight,';
   title2 'and Weight Loss'; 

The following output shows the results:

Table of Mean Values for Each Team

                      Mean Starting Weight, Ending Weight,                     1
                                and Weight Loss

          |                  |                 Mean                 |
          |                  |--------------------------------------|
          |                  |StartWeight | EndWeight  |    Loss    |
          |Team              |            |            |            |
          |------------------|            |            |            |
          |red               |      175.33|      158.33|       17.00|
          |yellow            |      169.50|      150.50|       19.00|
A portion of a SAS program that begins with a PROC (procedure) statement and ends with a RUN statement (or is ended by another PROC or DATA statement) is called a PROC step. Both of the PROC steps that create the previous two outputs comprise the following elements:

Previous Page | Next Page | Top of Page