SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Basic Concepts
Lesson Summary

 

This page contains


I. Text Summary

To go to the page where a task, programming feature, or concept was presented, select a link.


Components of SAS Programs
SAS programs consist of two types of steps: DATA steps and PROC (procedure) steps. These two steps, alone or combined, form all SAS programs. A SAS program may consist of a DATA step, a PROC step, or any combination of DATA and PROC steps. DATA steps typically create or modify SAS data sets but can also be used to produce custom-designed reports. PROC steps typically analyze and process data in the form of a SAS data set but can sometimes create SAS data sets containing the results of the procedure. PROC steps control a library of prewritten routines (procedures) that perform tasks on SAS data sets, such as listing, sorting, and summarizing data.

Characteristics of SAS Programs
SAS programs are made up of SAS statements. A SAS statement usually begins with a SAS keyword and always ends with a semicolon. A DATA step begins with the keyword DATA. A PROC step begins with the keyword PROC. SAS statements are free-format, so they can begin and end anywhere on a line, one statement can continue over several lines, and several statements can be on a line. Blanks or special characters separate "words" in a SAS statement.

Processing SAS Programs
When you submit a SAS program, SAS software reads SAS statements and checks them for errors. When it encounters a DATA, PROC, or RUN statement, SAS software executes the current step in the program.

Log Messages
Each time a step is executed, SAS software generates a log of the processing activities and the results of the processing. The SAS log collects messages about the processing of SAS programs and any errors that may occur. The results of processing vary, depending on the program executed.

Referencing SAS Files
To reference a SAS file, you use a two-level name, libref.filename. In the two-level name, libref is the libref for the SAS library that contains the file, and filename is the name of the file itself. A period separates the libref and filename. If the libref is not Work, the SAS file is a permanent file. Optionally, you can use a one-level name (the filename only) to reference a file in a temporary SAS library.

Overview of SAS Data Sets
For many of the data processing tasks you perform with SAS software, you access data in the form of a SAS data set and use SAS programs to analyze, manage, or present the data. Conceptually, a SAS data set is a file consisting of two parts: a descriptor portion and a data portion. Some SAS data sets also contain an index, which enables SAS software to locate records in the data set.

Data Portion
The data portion of a SAS data set is a collection of data values that are arranged in a rectangular table. Rows (called observations) in the data set correspond to records or data lines in a raw data file or external database. An observation is the information about each entity in a SAS data set. Columns (called variables) in the data set correspond to fields in a raw data file or external database. A variable is the set of data values that describes a given characteristic. The rectangular arrangement of rows and columns in a SAS data set implies that every variable must exist for each observation. If a data value is unknown for a particular observation, a missing value is recorded in the SAS data set.

Descriptor Portion
The descriptor portion of a SAS data set contains information about the data set, including
  • the name of the data set
  • the date and time the data set was created
  • the number of observations
  • the number of variables.

Variable Attributes
Besides general information about the data set, the descriptor portion contains attribute information for each variable in the data set. The attribute information includes the variable's name, type, length, format, informat, and label.

How SAS Files Are Stored
All SAS files are stored in a SAS library, which is a collection of SAS files, such as SAS data sets and catalogs. In some operating environments, a SAS library is a physical collection of files. In others, the files are only logically related. In the Windows and UNIX environments, a SAS library is typically a group of SAS files in the same folder or directory.

Referencing SAS Libraries
To access a SAS library, you assign it a name (also known as a libref, or library reference). You can think of librefs as temporary nicknames that you use to identify SAS libraries during a SAS session.

Types of SAS Files
The individual files in a SAS library are considered members of the library. The most commonly used types of SAS files include Table, View, Catalog, and Mddb.

Storing Files Temporarily or Permanently
Depending on the libref you use, you can store SAS files in temporary SAS libraries or in permanent SAS libraries.
  • Temporary SAS files created during the session are held in a special work space that is assigned the default libref Work. If you don't specify a libref when you create a file (or if you specify Work), the file is stored in the temporary library. Once you end the session, the temporary library is deleted.

  • To store files permanently in a SAS library, you assign it a libref other than the default Work. For example, by assigning the libref Clinic to a SAS library, you specify that files within the library be stored until you delete them.

The Sashelp and Sasuser Libraries
SAS software automatically defines two permanent libraries, Sashelp and Sasuser, at the beginning of each SAS session.


II. Points to Remember
  • Before referencing SAS files, you must assign a name (libref, or library reference) to the library where the files are stored (or specify that SAS software assign the name automatically).

  • You can store SAS files temporarily or permanently.

  • A variable's length (the number of bytes used to store it) is related to its type. Character variables can be up to 32K long. Numeric variables have a default length of 8. Numeric values (no matter how many digits they contain) are stored as floating point numbers in 8 bytes of storage, unless you specify another length.


back||next

 

Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.
Terms of Use & Legal Information | Privacy Statement