By Ajeet Kumar
/* Array Program
Number: 1 */
data result;
input Name $ Phy
Chem Bio Math Eng ;
total = Phy +
Chem + Bio + Math + Eng ;
datalines;
AA 26 38 76 86 83
BB . 68 3 43 43
CC 44 39 79 79 5
;
run;
proc print data=result;
run;
/* Array Program
Number: 2 */
data result;
input Name $ Phy
Chem Bio Math Eng ;
total = sum(Phy ,
Chem , Bio , Math , Eng);
datalines;
AA 26 38 76 86 83
BB . 68 3 43 43
CC 44 39 79 79 5
;
run;
proc print
data=result;
run;
/* Array Program
Number: 3 */
data result;
input Name $ Phy
Chem Bio Math Eng ;
array subject{5}
Phy Chem Bio Math Eng ;
total =
subject[1] + subject[2] + subject[3] + subject[4] + subject[5];
datalines;
AA 26 38 76 86 83
BB 2 68 3 43 43
CC 44 39 79 79 5
;
run;
proc print
data=result;
run;
/* Array Program
Number: 4 */
data result;
input Name $ Phy
Chem Bio Math Eng ;
array subject{5}
Phy Chem Bio Math Eng ;
total =
subject[1] + subject[2] + subject[3] + subject[4] + subject[5];
datalines;
AA 26 38 76 86 83
BB 2 . 3 43 43
CC 44 39 79 79 5
;
run;
proc print
data=result;
run;
/* Array Program
Number: 5 */
data result;
input Name $ Phy
Chem Bio Math Eng ;
array subject{5}
Phy Chem Bio Math Eng ;
total =
sum(subject[1] , subject[2] , subject[3] , subject[4] , subject[5]);
datalines;
AA 26 38 76 86 83
BB 2 . 3 43 43
CC 44 39 79 79 5
;
run;
proc print
data=result;
run;
/* Array Program
Number: 6 */
data result;
input Name $ Phy
Chem Bio Math Eng ;
array subject{5}
Phy Chem Bio Math Eng ;
total =
sum(subject[1] , subject[2] , subject[3] , subject[4] , subject[5]);
average =
mean(subject[1] , subject[2] , subject[3] , subject[4] , subject[5]);
datalines;
AA 26 38 76 86 83
BB 2 . 3 43 43
CC 44 39 79 79 5
;
run;
proc print
data=result;
run;
/* Array Program Number:
7 */
data result;
input Name $ Phy
Chem Bio Math Eng ;
array subject{5}
Phy Chem Bio Math Eng ;
total =
sum(subject[1] , subject[2] , subject[3] , subject[4] , subject[5]);
average =
total/5;
datalines;
AA 26 38 76 86 83
BB 2 . 3 43 43
CC 44 39 79 79 5
;
run;
proc print
data=result;
run;
/* Array Program
Number: 8 */
data result;
input Name $ Phy
Chem Bio Math Eng ;
array subject{5}
Phy Chem Bio Math Eng ;
do i=1 to 5;
total +
subject[i];
end;
output;
drop i;
datalines;
AA 26 38 76 86 83
BB 2 . 3 43 43
CC 44 39 79 79 5
;
run;
proc print
data=result;
run;
/* Array Program
Number: 9 */
data gotos;
INPUT X1-X10 @@;
array x x1-x10 ;
count = 0;
do i=1 to 10;
if x{i} = . then
count + 1;
if count > 5
then goto done:
end;
done: if count
< 5 then output;
CARDS;
1 2 3 4 5 . 8 7 8
9 10
8 7 8 9 . 1 2 2 3
4
;
run;
proc print
data=gotos;run;
No comments:
Post a Comment