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