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
Onyx | Level 15

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



sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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