So I have a basketball season summary for the lineup configurations that a team played.
For the first observation, this lineup;
Points = 23
Assist = 10
Jordan, Kobe, and Barkley are in the lineup (Jordan Kobe and Barkley =1)
Bird and Jokic are not in the lineup (Bird and Jokic =0)
Location is at home (Location =1)
Result is a win (Result = 1)
DATA cars1; INPUT Points Assist Jordan Kobe Bird Barkley Jokic Location Result; lineup;
23 10 1 1 0 1 0 1 1
33 12 1 0 1 1 0 0 1
12 3 0 1 1 0 1 1 0
44 20 1 0 1 0 1 1 0
50 14 1 1 1 0 1 0 0 ; RUN;
I want something like this using proc report.
Result =1(Win) | Result =1(Win) | Result =0(Loss) | Result =0(Loss) | Location = 1 (Home) | Location = 1 (Home) | Location = 0 (Away) | Location = 0 (Away) | |
Players | Points (MEAN) | Assist(MEAN) | Points (MEAN) | Assist(MEAN) | Points (MEAN) | Assist(MEAN) | Points (MEAN) | Assist(MEAN) |
Jordan =1 | ||||||||
Jordan = 0 | ||||||||
Kobe = 1 | ||||||||
Kobe = 0 | ||||||||
Bird = 1 | ||||||||
Bird = 0 | ||||||||
Barkley = 1 | ||||||||
Barkley = 0 | ||||||||
Jokic = 1 | ||||||||
Jokic = 0 |
This would be a lot easier if you had the player's name as a value of the variable named PLAYER, rather than player's names in columns going across. If you had this, PROC REPORT would be able to do this. For example, here is partial code to re-arrange the data into a more useful form. I leave the rest of the coding for you to do, following along what I have done.
data re_arrange;
length player $ 16;
set cars1;
player='Jordan';
in_lineup=jordan;
output;
player='Chamberlain';
in_lineup=Chamberlain;
output;
drop jordan--jokic;
run;
here is partial code to obtain the table, I trust you can modify it to account for the rest of the variables and players.
proc report data=re_arrange;
columns player in_lineup result,(points assist);
define player/group;
define in_lineup/group;
define result/across;
define points/sum;
define assist/sum;
run;
This would be a lot easier if you had the player's name as a value of the variable named PLAYER, rather than player's names in columns going across. If you had this, PROC REPORT would be able to do this. For example, here is partial code to re-arrange the data into a more useful form. I leave the rest of the coding for you to do, following along what I have done.
data re_arrange;
length player $ 16;
set cars1;
player='Jordan';
in_lineup=jordan;
output;
player='Chamberlain';
in_lineup=Chamberlain;
output;
drop jordan--jokic;
run;
here is partial code to obtain the table, I trust you can modify it to account for the rest of the variables and players.
proc report data=re_arrange;
columns player in_lineup result,(points assist);
define player/group;
define in_lineup/group;
define result/across;
define points/sum;
define assist/sum;
run;
Well duh @aswift13 , I typed sum but I should have typed mean.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.