Hello
I want create report using proc report.
Please see the code.
I want to add one more column of PCT from total for each team.
For category a we need to get 100/550=18%
For category a we need to get 450/550=82%
Data tbl;
input ID Team $ Country $ sales;
cards;
1 a UK 10
2 a UK 20
3 a UK 30
4 a USA 40
5 b UK 50
6 b UK 60
7 b USA 70
8 b USA 80
9 b USA 90
10 b USA 100
;
run;
Proc report data=tbl nowd;
columns Team Country,(sales=salespctsum) ;
define Team/ group ;
define Country/across order=formatted ;
define salespctsum / pctsum format=percent9.1 ;
rbreak after/ summarize;
run;
Since you want a summary table, why not using PROC TABULATE ?
Data tbl;
input ID Team $ Country $ sales;
cards;
1 a UK 10
2 a UK 20
3 a UK 30
4 a USA 40
5 b UK 50
6 b UK 60
7 b USA 70
8 b USA 80
9 b USA 90
10 b USA 100
;
run;
Proc tabulate data=tbl ;
class Team Country;
var sales;
table team all,country*sales*colpctsum=' ' sales='total'*pctsum=' ';
run;
Hi:
For a simple PCTSUM, you don't need to move to TABULATE, although that does give you more percent keyword choices. You only need to modify your PROC REPORT to use SALES again on the report, but not UNDER COUNTRY, as shown below:
Cynthia
Proc report data=tbl nowd;
columns Team Country,(sales=salespctsum) sales=tot sales=cpct;
define Team/ group ;
define sales / sum;
define Country/across 'Country Percent' order=formatted ;
define salespctsum / pctsum format=percent9.1 ;
define tot / 'Total';
define cpct / pctsum format=percent9.1;
rbreak after/ summarize;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.