BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am trying to create a table that has the "n" and "%" in separate rows, so that the percentages can be read from the table straight across, instead of having the "n" and "%" columns next to each other. Here is my current code - any ideas? Thanks in advance! (Q1 is a 1-5 scale.)

proc tabulate data=mvr.ready_08_6Jun(where=(wave ge 230)) format=9.1 noseps formchar(1,8,2,3,4,5,6,7,9,10,11)='||----|+|---';
title 'Table 1a';
format wave wave. q1 sat. total total.;
class wave q1 total;
table (q1="OVERALL SATISFACTION" total=' '),
wave*(pctn*f=p8r6.0 N*f=4.0)/rts = 35
box="Table 1a. OVERALL SATISFACTION" misstext=' ';
keylabel pctn = "(%)";
run;
2 REPLIES 2
Olivier
Pyrite | Level 9
Hello.

In your example, what you need to do is move the *(PCTN ... F=4.0) part BEFORE the comma, meaning that you want separate LINES instead of COLUMNS (what is after comma defines columns).
I've tested this little code, slightly different from yours, but showing the idea.
[pre]
PROC TABULATE DATA=sashelp.prdsale ;
CLASS region product year ;
VAR actual ;
TABLE (region product)*(SUM="N"*F=12. PCTSUM="%"*F=12.2),
actual=""*year="" ;
RUN ;
[/pre]
Regards,
Olivier
deleted_user
Not applicable
Thank you so much, Olivier! That is exactly what I needed to know!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1008 views
  • 0 likes
  • 2 in conversation