CSULB_STAT475_handout14

CSULB_STAT475_handout14 - STAT 475 Chapter 16 PROCESSING...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
STAT 475 Chapter 16 PROCESSING VARIABLES WITH ARRAYS CREATING ONE-DIMENSIONAL ARRAYS A SAS array is a temporary grouping of variables under a single name. An array exists only for the duration of the DATA step. Usage of the ARRAY statement reduces the number of statements that are required for processing variables. By grouping variables into a one-dimensional array, it is possible to process all these variables in a single DO loop. The syntax is data newdataset_name ; set dataset_name ; array array_name { dimension } variable1 variable2 …; do index_variable =1 to dimension ; variable_name { index_variable }= expression(array_name{index_variable} ) ; end; run; The dimension specifies the number of elements variable1, variable2 , etc. in the array called array_name . The dimension may be enclosed in either parentheses, braces, or brackets array days(4) mon tue wed thr; or array days{4} mon tue wed thr; or array days[4] mon tue wed thr; Specifying the dimension of an array by an asterisk (*) instructs SAS to determine the dimension by counting the number of elements. array x{*} total1 total5 total6 total18; To compute the number of elements in an array, use the DIM function. DIM( array_name ) may be used as the stop value for the index_variable in a DO loop. array x{*} total1 total5 total6 total18; do i=1 to dim(x); SAS statements; end; 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The elements of the array are referenced as variable1 = array_name {1}, … variable_dimension = array_name
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

CSULB_STAT475_handout14 - STAT 475 Chapter 16 PROCESSING...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online