proc sql;
create table have as
select Team,
sum(nAtBat) as Tot_Num_Bats,
sum(nHits) as Tot_Num_Hits
from sashelp.baseball
where team in ('Atlanta','Baltimore','
Boston','California','Chicago','Cincinnati','
Cleveland')
group by Team
having sum(nAtBat) >0
order by Team
;quit;
proc report data=have NOWD Wrap style(summary)=Header;
columns Team Tot_Num_Bats Tot_Num_Hits Pct_Num_Bats;
define Tot_Num_Bats / sum "Total # Bats" ;
define Tot_Num_Hits / sum "Total # Hits" ;
define Pct_Num_Bats /computed f=percent8.2 "%Hits" ;
compute Team;
endcomp;
rbreak after / summarize style (summary)= Header;
compute after;
Team = 'Total';
endcomp;
run;
I can get the total at the bottom.
How can I get the percentage of the total to show in the far right column (in this case Pct_Num_Bats).
I want to do the same for Tot_Num_Hits
proc report data=have NOWD Wrap style(summary)=Header;
columns Team Tot_Num_Bats Tot_Num_Hits Pct_Num_Bats;
define Tot_Num_Bats / sum "Total # Bats" ;
define Tot_Num_Hits / sum "Total # Hits" ;
define Pct_Num_Bats /computed f=percent8.2 ;
compute Pct_Num_Bats;
Pct_Num_Bats= Tot_Num_Hits.sum/Tot_Num_Bats.sum;
endcomp;
rbreak after / summarize style (summary)= Header;
compute after;
Team = 'Total';
endcomp;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.