This example
creates variables in the array TEST and assigns them the initial values
90, 80, and 70. It reads values into another array named SCORE and
compares each element of SCORE to the corresponding element of TEST.
If the value of the element in SCORE is greater than or equal to the
value of the element in TEST, the variable NewScore is assigned the
value in the element SCORE, and the OUTPUT statement writes the observation
to the SAS data set.
The INPUT statement
reads a value for the variable named ID and then reads values for
all the variables in the SCORE array.
options nodate pageno=1 linesize=80 pagesize=60;
data score1(drop=i);
array test{3} t1-t3 (90 80 70);
array score{3} s1-s3;
input id score{*};
do i=1 to 3;
if score{i}>=test{i} then
do;
NewScore=score{i};
output;
end;
end;
datalines;
1234 99 60 82
5678 80 85 75
;
proc print noobs data=score1;
title 'Data Set SCORE1';
run;
The following output
shows the SCORE1 data set.
Assigning Initial Values to the Elements of an Array
Data Set SCORE1 1
New
t1 t2 t3 s1 s2 s3 id Score
90 80 70 99 60 82 1234 99
90 80 70 99 60 82 1234 82
90 80 70 80 85 75 5678 85
90 80 70 80 85 75 5678 75