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

Hello, my question regarding proc tabulate is how to get the categorical variable name to appear to the left of the categorical levels of the variable, particularly in Excel output. 

The categorical variable name is Gender and the categorical levels are Male and Female.

For example, my current proc tabulate output in Excel looks like this (please ignore color scheme): 

Currently_Have.png

 

I would like the output in Excel to look like this below (please ignore the color scheme):

Wanted_Output.png

 

Are there any options, statements etc. for proc tabulate to change to that kind of output? Are there ways to do this in ODS Excel? 

Please let me know if there's anything else I need to provide. 

 

Thanks in advance. 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
 set sashelp.class;
 dummy='Gender';
run;
proc tabulate data=have;
class dummy sex age;
table dummy=' '*sex=' ',age=' '*n=' ';
run;

Ksharp_0-1622549256517.png

 

View solution in original post

7 REPLIES 7
Ksharp
Super User
1) Create a dummy variable which value is "Gender". like :
dummy="Gender" ;

2) use PROC REPORT instead .
Ksharp
Super User
data have;
 set sashelp.class;
 dummy='Gender';
run;
proc tabulate data=have;
class dummy sex age;
table dummy=' '*sex=' ',age=' '*n=' ';
run;

Ksharp_0-1622549256517.png

 

stayhydrated
Fluorite | Level 6
This is a very easy solution, thank you so much!
Ksharp
Super User
Yeah. It is Chinese F and M. I am using sas in Chinese version .
Reeza
Super User
PROC REPORT seems like the easiest solution. FYI - you can use the OUT option on PROC TABULATE to get the data/stats and then use PROC REPORT to display the summary stats and data as desired with more control.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 7 replies
  • 752 views
  • 4 likes
  • 4 in conversation