BookmarkSubscribeRSS Feed
Uzeus7869
Calcite | Level 5

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
ChrisNZ
Tourmaline | Level 20

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.

PGStats
Opal | Level 21

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

PG
yabwon
Amethyst | Level 16

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



hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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