Start Day 4;



Array Array Array

The array statement defines a set of variables as elements of an array.

The array variables has to be either all numeric or all character.

Syntax: ARRAY array-name{subscript}

;

Example:

Array v(5) v1-v5; *var1 to var5 are variables in the data set.

Array score(4) score_a score_c score_f score_t;

Array bb(3) (10 20 30) ; * Initialize numeric array;

Array aa(3) $3. (‘AAA’ ‘BBB’ ‘CCC’); * Initialize character array;

Array week(7) $3. ('Sun' 'Mon' 'Tue' 'Wed' 'Thu' 'Fri' 'Sat');

Array wk(7) $3. ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');

Example 1: Use array to perform calculations on a group of variables.

*** generate data;

data test_array(drop=i r);

length ID 8;

array mth(12) mth1-mth12;

do ID=1 to 100;

do i=1 to 12;

mth(i) = int(ranuni(1)*1000);

r=ranuni(0);

if r ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download