Calcite | Level 5

## excludes the lowest value when calculating mean in SAS?

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

3 REPLIES 3
Tourmaline | Level 20

## Re: excludes the lowest value when calculating mean in SAS?

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.

Opal | Level 21

## Re: excludes the lowest value when calculating mean in SAS?

How would you calculate the mean without excluding the lowest values?

PG
Onyx | Level 15

## Re: excludes the lowest value when calculating mean in SAS?

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; ``````

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation

Discussion stats
• 3 replies
• 877 views
• 0 likes
• 4 in conversation