BookmarkSubscribeRSS Feed
MiraKr_
Obsidian | Level 7

Hello,

I am looking for a way to request proc tabulate to display the output with N(%) in the same column. Is that possible using proc tabulate or do I need proc template?

 

proc tabulate data=dquest.pooled_dri_quest missing;
class STUDYID sex ;
tables (sex all='Overall' ), STUDYID*(n='N'*F=6.0 colpctn='%'*F=6.1) (all='Pooled')*(N='N'*F=6.0 COLPCTN='%'*F=6.1);
run;

 

Output:

  Study Identifier Pooled
DRI12544 EFC13579
N % N % N %
Sex 490 63.1 1197 62.9 1687 63
F
M 286 36.9 705 37.1 991 37
Overall 776 100 1902 100 2678

100

 

I want this:

  Study Identifier Pooled
DRI12544 EFC13579
N (%) N (%) N (%)
Sex 490 (63.1) 1197 (62.9) 1687 (63.0)
F
M 286 (36.9) 705 (37.1) 991 (37.0)
Overall 776 (100) 1902 (100) 2678 (100)

 

Many Thanks,
MK

2 REPLIES 2
Reeza
Super User

It's not possible with PROC TABULATE. If I need that type of reporting, I create the field as text within a data step and use PROC PRINT or REPORT to display it. 

 


@MiraKr_ wrote:

Hello,

I am looking for a way to request proc tabulate to display the output with N(%) in the same column. Is that possible using proc tabulate or do I need proc template?

 

proc tabulate data=dquest.pooled_dri_quest missing;
class STUDYID sex ;
tables (sex all='Overall' ), STUDYID*(n='N'*F=6.0 colpctn='%'*F=6.1) (all='Pooled')*(N='N'*F=6.0 COLPCTN='%'*F=6.1);
run;

 

Output:

  Study Identifier Pooled
DRI12544 EFC13579
N % N % N %
Sex 490 63.1 1197 62.9 1687 63
F
M 286 36.9 705 37.1 991 37
Overall 776 100 1902 100 2678

100

 

I want this:

  Study Identifier Pooled
DRI12544 EFC13579
N (%) N (%) N (%)
Sex 490 (63.1) 1197 (62.9) 1687 (63.0)
F
M 286 (36.9) 705 (37.1) 991 (37.0)
Overall 776 (100) 1902 (100) 2678 (100)

 

Many Thanks,
MK


 

 

ballardw
Super User

You can create output that with print similar to that on paper but not in electronic form with proc tabulate. Keys are using the correct, possibly custom to provide (), format for the %, justification of values in the cells, using style overrides to remove any cell border and likely cellpadding settings between the N and %.

 

The values will still be in separate "columns" but the decision is yours.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 795 views
  • 0 likes
  • 3 in conversation