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

Hi,

 

with proc tabulate I have this output :

 

  mean median
Age 30 25
Revenue 2700 2600

 

and what I want to have is this form :

Age mean 30
  median 25
Revenue mean 2700
  median 2600

 

Is this possible? 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
majdi_ka
Obsidian | Level 7

Based on your previous post, I edited the code because I have only numeric variables :

 

PROC TABULATE
DATA=SASHELP.CLASS
	
	;
	VAR Height Age;
	TABLE 
		/* ROW Statement */
		Height * Mean={LABEL="Mean"} Height={LABEL=""} * Median={LABEL="Median"} 
		Age * Mean={LABEL="Mean"} Age={LABEL=""} * Median={LABEL="Median"} ,
		/* COLUMN statement */
		ALL=' ' 		;
	;

RUN;

And I have the result that I want Man Very Happy :

 

Height Mean 62.34
  Median 62.80
Age Mean 13.32
  Median 13.00

 

What I looked for is the " , ALL=' '  " 

 

Thanks a lot @Reeza!

View solution in original post

6 REPLIES 6
Reeza
Super User
Yes, change your table statement. If you post your code, someone can suggest the change from the current code.
majdi_ka
Obsidian | Level 7

@Reeza,

OK, it's a simple code:

 

proc tabulate data=have;
  var age revenue;
  tables
     /*line*/
     age
     revenue,

     /*column*/
     (mean median);
run;

      

 

MK

Reeza
Super User
What does the following give you:

tables (age revenue)*(mean median);
majdi_ka
Obsidian | Level 7

it gives a vertical summary table like this :

 

Age Revenue
mean median mean median
Reeza
Super User
PROC TABULATE
DATA=SASHELP.CLASS
	
	;
	
	VAR Height;
	CLASS Sex /	ORDER=UNFORMATTED MISSING;
	CLASS Age /	ORDER=UNFORMATTED MISSING;
	TABLE 
		/* ROW Statement */
		Sex *Age  *(Height * Mean={LABEL="Average"} Height * Median={LABEL="Median"} ),
		/* COLUMN statement */
		ALL=' ' 		;
	;

RUN;
majdi_ka
Obsidian | Level 7

Based on your previous post, I edited the code because I have only numeric variables :

 

PROC TABULATE
DATA=SASHELP.CLASS
	
	;
	VAR Height Age;
	TABLE 
		/* ROW Statement */
		Height * Mean={LABEL="Mean"} Height={LABEL=""} * Median={LABEL="Median"} 
		Age * Mean={LABEL="Mean"} Age={LABEL=""} * Median={LABEL="Median"} ,
		/* COLUMN statement */
		ALL=' ' 		;
	;

RUN;

And I have the result that I want Man Very Happy :

 

Height Mean 62.34
  Median 62.80
Age Mean 13.32
  Median 13.00

 

What I looked for is the " , ALL=' '  " 

 

Thanks a lot @Reeza!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 6 replies
  • 1272 views
  • 2 likes
  • 2 in conversation