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

Hi All,

 

I'm looking for a way to create output using proc tabulate two-way table vertically.

 

Please find Sample.xlsx attached.

 

Regards,

Thokozani

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

Hi

 

Using the task Summary Tables you can create something like this. The layout definition would look like

Capture.PNG

It is using sashelp.cars.

 

And here a code example generated by SAS Enterprise Guide

 

PROC TABULATE
  DATA=SASHELP.CARS
  FORMAT=NLNUM14.
;
  WHERE( Origin IN ('Asia','Europe'));
  VAR Invoice;
  CLASS Type /  ORDER=UNFORMATTED MISSING;
  CLASS Origin /  ORDER=UNFORMATTED MISSING;
  CLASS DriveTrain /  ORDER=UNFORMATTED MISSING;

  TABLE /* Row Dimension */
    Type={LABEL=""} 
      ALL={LABEL="Total (ALL)"},
      /* Column Dimension */
    Origin={LABEL=""}*(
      DriveTrain={LABEL=""}*
      Invoice={LABEL=""}*
      Sum={LABEL=""} 
      ALL={LABEL="Total (ALL)"}*
      Invoice={LABEL=""}*
      Sum={LABEL=""});
    ;
RUN;

 

Bruno

 

 

 


Capture.PNG

View solution in original post

2 REPLIES 2
BrunoMueller
SAS Super FREQ

Hi

 

Using the task Summary Tables you can create something like this. The layout definition would look like

Capture.PNG

It is using sashelp.cars.

 

And here a code example generated by SAS Enterprise Guide

 

PROC TABULATE
  DATA=SASHELP.CARS
  FORMAT=NLNUM14.
;
  WHERE( Origin IN ('Asia','Europe'));
  VAR Invoice;
  CLASS Type /  ORDER=UNFORMATTED MISSING;
  CLASS Origin /  ORDER=UNFORMATTED MISSING;
  CLASS DriveTrain /  ORDER=UNFORMATTED MISSING;

  TABLE /* Row Dimension */
    Type={LABEL=""} 
      ALL={LABEL="Total (ALL)"},
      /* Column Dimension */
    Origin={LABEL=""}*(
      DriveTrain={LABEL=""}*
      Invoice={LABEL=""}*
      Sum={LABEL=""} 
      ALL={LABEL="Total (ALL)"}*
      Invoice={LABEL=""}*
      Sum={LABEL=""});
    ;
RUN;

 

Bruno

 

 

 


Capture.PNG
Ksharp
Super User

You can't split these two table completely .

 

data have;
 set sashelp.cars;
 retain dummy ' ' x .;
run;

proc tabulate data=have;
class Type Origin DriveTrain ;
class dummy /missing style={background=yellow cellwidth=1cm};
classlev dummy /style={background=yellow};
var Invoice x;
table Type all,Origin*Invoice*(n mean std) 
      dummy=''*x=''*sum=''*{style={background=yellow}}
      DriveTrain*Invoice*(n mean std)
      /printmiss misstext='  ';
run;

 

x.png

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1562 views
  • 2 likes
  • 3 in conversation