Hello
In the following example to proc tabulate I want to do the following:
1- Add a title '2019' above SUM(X1) and PCTSUM(X1)
1- Add a title '2018' above SUM(X2) and PCTSUM(X2)
Can anyone edit the code in order to get it please?
Data RawData;
Input ID Z X1 X2;
cards;
1 1 10 20
2 1 15 30
3 1 20 40
4 1 25 50
5 2 30 60
6 2 35 70
7 2 40 80
8 2 45 90
9 2 50 100
10 2 55 110
;
run;
proc tabulate data=RawData f=comma12.1;
class Z ;
var X1 X2 ;
table Z='' ALL, X1=''*(n='Customers'* f=comma.
pctn='%Customers'*f=pctfmt.
SUM='SumSales2019'
PCTSUM='%SumSales2019'*f=pctfmt.)
X2=''*( SUM='SumSales2018'
PCTSUM='%SumSales2018'*f=pctfmt.);
run;
Split the X1 layout:
proc tabulate data=RawData f=comma12.1;
class Z ;
var X1 X2 ;
table Z='' ALL, X1=' '*(n ='Customers' *f=comma.
pctn ='%Customers' *f=pctfmt.)
X1='2019'*(sum ='SumSales2019'
pctsum='%SumSales2019'*f=pctfmt.)
X2='2018'*(sum ='SumSales2018'
pctsum='%SumSales2018'*f=pctfmt.);
run;
Split the X1 layout:
proc tabulate data=RawData f=comma12.1;
class Z ;
var X1 X2 ;
table Z='' ALL, X1=' '*(n ='Customers' *f=comma.
pctn ='%Customers' *f=pctfmt.)
X1='2019'*(sum ='SumSales2019'
pctsum='%SumSales2019'*f=pctfmt.)
X2='2018'*(sum ='SumSales2018'
pctsum='%SumSales2018'*f=pctfmt.);
run;
Does the reply above answer your question?
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.