SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Search||next

Processing Variables with Arrays
Lesson Overview


Introduction

In DATA step programming, you often need to perform the same action on more than one variable. Although you can process variables individually, it is easier to handle them as a group. You can do this by using array processing.

For example, using an array and DO loop, the program below eliminates the need for 365 separate programming statements to convert the daily temperature from Fahrenheit to Celsius for the year.

     data work.report;
        set master.temps;
        array daytemp(365) day1-day365;
        do i=1 to 365;
           daytemp(i)=5*(daytemp(i)-32)/9;
        end;
     run;

This lesson teaches you how to define an array and reference elements of the array in the DATA step.

This lesson contains 30 pages and takes approximately 45-60 minutes to complete.


Objectives

After completing this lesson, you will be able to

  • group variables into one- and two-dimensional arrays
  • perform an action on array elements
  • create new variables using an ARRAY statement
  • assign initial values to array elements
  • create temporary array elements using an ARRAY statement.


Prerequisites

Before taking this lesson, you should have completed the following lessons:

Getting Started with SAS Programming

Creating and Modifying Variables

DATA Step Processing

  ||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement