Syntax, ARRAY statement:
ARRAY array-name{dimension} <elements>;
|
array sales{4} qtr1 qtr2 qtr3 qtr4;
array sales{4} qtr1 qtr2 qtr3 qtr4;
array sales{96:99} totals96 totals97 totals98 totals99;
array sales{*} qtr1 qtr2 qtr3 qtr4;
( ) array sales{4} qtr1 qtr2 qtr3 qtr4; [ ]
array sales{4} qtr1 qtr2 qtr3 qtr4;
array sales{4} qtr1-qtr4;
Variables
|
Form
|
---|---|
a numbered range of
variables
|
Var1-Varn
|
all numeric variables
|
_NUMERIC_
|
all character variables
|
_CHARACTER_
|
all character or all
numeric variables
|
_ALL_
|
Qtr1 Qtr2 Qtr3 Qtr4 → Qtr1-Qtr4
array sales{4} qtr1-qtr4;
array sales{96:99} totals96-totals99;
Amount Rate Term → _NUMERIC_
array sales{*} _numeric_;
FrstName LastName Address → _CHARACTER_
array sales{*} _character_;
FrstName LastName Address → _ALL_
Amount Rate Term → _ALL_
array sales{*} _all_;
data work.report(drop=day);
set master.temps;
array wkday[7] mon tue wed thr fri sat sun;
do day=1 to 7;
if wkday{day}>95 then output;
end;
run;
data work.weights(drop=day);
set master.class;
array wt[6] w1-w6;
do day=1 to 6;
wt{day}=wt{day}*2.2;
end;
run;
data work.new(drop=day);
set master.synyms;
array term[9] also1-also9;
do day=1 to 9;
if term{day} ne ' ' then output;
end;
run;
array quarter[4] jan apr jul oct; do qtr=1 to 4; YearGoal=quarter{qtr}*1.2; end;
1 2 3 4 array quarter[4] jan apr jul oct; do qtr=1 to 4; YearGoal=quarter{qtr}*1.2; end;
Syntax, ARRAY reference:
array-name[subscript]
|
array quarter{4} jan apr jul oct; do i=1 to 4; YearGoal=quarter{i}*1.2; end;
1 array quarter{4} jan apr jul oct; do i=1 to 4; YearGoal=quarter{1}*1.2; end; 2 array quarter{4} jan apr jul oct; do i=1 to 4; YearGoal=quarter{2}*1.2; end; 3 array quarter{4} jan apr jul oct; do i=1 to 4; YearGoal=quarter{3}*1.2; end; 4 array quarter{4} jan apr jul oct; do i=1 to 4; YearGoal=quarter{4}*1.2; end;
data hrd.convert(drop=i); set hrd.fitclass; array wt{6} weight1-weight6; do i=1 to 6; wt{i}=wt{i}*2.2046; end; run;
data hrd.convert;
set hrd.fitclass;
array wt{6} weight1-weight6;
do i=1 to 6;
wt{i}=wt{i}*2.2046;
end;
run;
data hrd.convert; set hrd.fitclass; array wt{6} weight1-weight6; do i=1 to 6; wt{1}=wt{1}*2.2046; end; run;
data hrd.convert; set hrd.fitclass; array wt{6} weight1-weight6; do i=1 to 6; wt{i}=wt{i}*2.2046; end; run;
Syntax, DIM function:
DIM(array-name)
|
6
. data hrd.convert;
set hrd.fitclass;
array wt{*} weight1-weight6;
do i=1 to dim(wt);
wt{i}=wt{i}*2.2046;
end;
run;
data hrd.convert; set hrd.fitclass; array wt{*} weight1-weight6; do i=1 to dim(wt); wt{i}=wt{i}*2.2046; end; run; |
data hrd.convert; set hrd.fitclass; array wt{*} weight1-weight10; do i=1 to dim(wt); wt{i}=wt{i}*2.2046; end; run; |