In general it is best to think about what SAS code you want the macro to generate (instead of trying to think of clever ways to program in the macro language itself).
Since in this case you are generating a data step anyway you can just use SAS for all of your calculations. Which means you can just use a FORMAT to do the rounding of the values you write to the LOG.
Note that when you need to pass a varying amount of values to a macro just use a space delimited list.
%macro mktscore
(timetot=
,timeremain=
,labscores=
,qztot=
,qzincorrect=
);
data _null_;
array labscores (%sysfunc(countw(&labscores,%str( )))) _temporary_ (&labscores) ;
time=&timetot - &timeremain;
labscore=mean(of labscores[*]);
qzcorrect=&qztot-&qzincorrect;
qzscore=100*qzcorrect/&qztot;
one3rdtot=2/3*labscore+1/3*qzscore;
put 'time used: ' time :comma32.2 +(-1) 'm' ;
put (labscore qzcorrect qzscore one3rdtot) (= :32.2);
run;
%mend mktscore;
%mktscore
(timetot=120
,timeremain=8
,labscores=70 100 96 0 0 90 100 90 80 100 90 90 90 96 93 96 100
,qztot=24
,qzincorrect=7
);
Results
93 options mprint;
94 %mktscore
95 (timetot=120
96 ,timeremain=8
97 ,labscores=70 100 96 0 0 90 100 90 80 100 90 90 90 96 93 96 100
98 ,qztot=24
99 ,qzincorrect=7
100 );
MPRINT(MKTSCORE): data _null_;
MPRINT(MKTSCORE): array labscores (17) _temporary_ (70 100 96 0 0 90 100 90 80 100 90 90 90 96 93 96 100) ;
MPRINT(MKTSCORE): time=120 - 8;
MPRINT(MKTSCORE): labscore=mean(of labscores[*]);
MPRINT(MKTSCORE): qzcorrect=24-7;
MPRINT(MKTSCORE): qzscore=100*qzcorrect/24;
MPRINT(MKTSCORE): one3rdtot=2/3*labscore+1/3*qzscore;
MPRINT(MKTSCORE): put 'time used: ' time :comma32.2 +(-1) 'm' ;
MPRINT(MKTSCORE): put (labscore qzcorrect qzscore one3rdtot) (= :32.2);
MPRINT(MKTSCORE): run;
time used: 112.00m
labscore=81.24 qzcorrect=17.00 qzscore=70.83 one3rdtot=77.77
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
... View more