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

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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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