BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ronein
Onyx | Level 15

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; 
1 ACCEPTED SOLUTION

Accepted Solutions
VRKiwi
Obsidian | Level 7

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; 

    kk.PNG

View solution in original post

2 REPLIES 2
VRKiwi
Obsidian | Level 7

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; 

    kk.PNG

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1272 views
  • 3 likes
  • 3 in conversation