BookmarkSubscribeRSS Feed
zoeshrugged
Calcite | Level 5

Hi, I have two datasets and I have the points earned and the points given up for a list of sports teams. I want to find out the highest margin between points earned-points given up.

For example, if it was like this:

TeamPoints EarnedPoints Given up
Lions2010
Ravens3021
Broncos305

Then we would know the Broncos had the highest margin. How do I write a formula for this?

Any assistance would be greatly appreciated!!

2 REPLIES 2
stat_sas
Ammonite | Level 13

data have;
input team $ points_earned points_give;
cards;
Lions 20 10
Ravens 30 21
Broncos 30 5
;

proc sql;
select * from have
having points_earned-points_give=max(points_earned-points_give);
quit;

Loko
Barite | Level 11

Hello,

data have;
input  Team $ Points_Earned Points_Given_up ;
datalines;
Lions 20 10
Ravens 30 21
Broncos 30 5
Tigers 80 75
Baggers 80 55
;

data want (drop=i dif record) ;

length record $ 30;

do until(last);
set have end=last;
i+1;

if dif <Points_Earned-Points_Given_up then
do;
  dif=Points_Earned-Points_Given_up;
  record=i;
end;
else if dif=Points_Earned-Points_Given_up then
record=cats(i,"|",record);
end;


i=1;
if find(record,"|") then
do while (not(missing(scan(record,i,"| "))));
  acces=input(scan(record,i,"|"),8.);
  set have point=acces;
  output;
  i=i+1;
end;
else
do;
  acces=input(compress(record),8.);
  set have point=acces;
output;
end;
run;

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 1481 views
  • 0 likes
  • 3 in conversation