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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.