So, My professor asked me to create a SAS program to excludes the lowest midterm grades when computing the prefinal grades(mean of exams), I google it, and it's have nothing help there, I can't find appropriate code.
Thank you for help
So, My professor asked me to create a SAS program to excludes the lowest midterm grades when computing the prefinal grades(mean of exams), I google it, and it's have nothing help there, I can't find appropriate code.
Surely your professor also gave you hints as to how to do this.
How would you calculate the mean without excluding the lowest values?
Hi,
for small size data arrays sounds reasonable
all the best
Bart
options fullstimer;
data have;
do nums=1 to 5555555;
num=int(10*uniform(1234))+2;
if mod(nums,17) = 0 then num =.;
output;
end;
run;
data _null_;
if 0 then set have nobs=NOBS;
call symputX('NOBS', NOBS,'G');
stop;
run;
data want;
array _temp_[&nobs.] _temporary_;
x = .;
do until (EOF);
set have end=EOF curobs=curobs;
_temp_[curobs] = num;
x = x<>(-num);
end;
x = -x;
if x = .
then avg = .;
else do curobs = lbound(_temp_) to hbound(_temp_);
if _temp_[curobs] > x then
do;
s + _temp_[curobs];
c + 1;
end;
end;
avg = divide(s,c);
output;
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.