BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

What is the way that the value under "Type" variable will be in each row of the report ?

I want to see in each row the value of "Type" var

proc tabulate data=sashelp.cars;
class type Cylinders;
var Invoice;
Table type=""*Cylinders='',Invoice*(N SUM) /box='Type/Cylinders';
Run;
4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Try this

 

proc tabulate data=sashelp.cars;
class type Cylinders;
var Invoice;
Table Cylinders=''*type="",Invoice*(N SUM) /box='Type/Cylinders';
Run;
Ronein
Onyx | Level 15
Thank you but it is not as I want.
I want that for both class variables I will see the value in each row
RichardDeVen
Barite | Level 11

Proc REPORT can present the data the same way as in TABULATE, with the extra caveat of filling in the 'blank' cells.

 

By default a group cell is blank in subsequent row after it is presented the first time.  COMPUTE blocks can be used to track and replace the blank (missing) values with the current group value.

 

Example:

 

proc report data=sashelp.cars;
  columns type cylinders invoice,(n sum);
  define type / group;
  define cylinders / group;
  define n / format=8.;
  compute before type;
    type_held = type;
  endcomp;
  compute type;
    if missing(type) then type=type_held;
  endcomp;
run;

REPORT output:

 

RichardADeVenezia_0-1598267418522.png

Versus TABULATE output:

RichardADeVenezia_1-1598267477716.png

You can get the same aggregation output from Proc MEANS

 

proc means data=sashelp.cars noNOBS N SUM ;
  class type cylinders;
  var invoice;
run;

The default output does not repeat the type values.

 

RichardADeVenezia_2-1598268155046.png

 

Ronein
Onyx | Level 15
I have asked how to create the desired output via proc tabulate ....
Thank you for the answer but I wanted to understand how to see values of class variables in each row via proc tabulate.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1044 views
  • 0 likes
  • 3 in conversation