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

Hi, guys. I have a simple question regarding the proc report format:

Here is the data

data order;
input ordernumber$ product$ qrt;
cards;
##1 a 1000
##2 b 200
##3 c 3000
##4 a 200
;
run;

Here is my code:

 

proc report data=order;
column ordernumber product qrt;
define product /group;
define  ordernumber/display;
define qrt/display;
run;

This is a desirable format(on the top) I want to display and on the bottom is my layout:

shawn123_0-1588189068906.png

shawn123_1-1588189140708.png

 

My question is how can I change the product into a subtitle, and also is there any alternative way to make this report layout inside of the proc report 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi,

  @ballardw was correct, you can't really get the headers that way you show in the desired output. The way that @ballardw shows them is what PROC REPORT does. As far as PROC REPORT is concerned, the column headers should come first and then the values for the variable in the COMPUTE block.

  The Report Writing Interface, may be the only way to do it, but it still looks odd to me to have one value above the column headers and the other values below.

 

cynthia

View solution in original post

6 REPLIES 6
ballardw
Super User

A couple of starting points (maybe)

proc report data=order;
   columns product ordernumber qrt;
   define product / group noprint ;
   define ordernumber/ display '';
   define qrt/display '';
   compute before product;
      line  product $5.;
   endcomp;
run;


proc tabulate data=order;
   class product ordernumber;
   var qrt;
   tables product,
          ordernumber='',
          qrt='Units'*sum=''
          /box='Order number'
   ;
run;
 
shawn123
Obsidian | Level 7

Hi ballardw, Thank you so much for the answer. And sorry about my unclear picture. I remake the picture so that better express my desirable layout

shawn123_0-1588193168330.png

Also, I try the first code, I end up with the table below, is there any way I can show the product name first and then show the ordernumber row under each product?

shawn123_1-1410727741611.png

The proc tabulate I try it before, I have a very similar code as you did(code and picture is shown below), I just make data into one table

 

proc tabulate data=order;
   class product ordernumber;
   var qrt;
   tables product*ordernumber,qrt='qrt'*sum=''
          /box=' ';
run;

shawn123_2-1410727802330.png

I am struggle on how to move the product name above the ordernumber row and insert a few more "ordernumber" rows in between. 

ballardw
Super User

Calling @Cynthia_sas

Your request about showing the Ordernumber and units label one time only and in that position is beyond my skill set with proc report.

 

And my tabulate code used the page dimension and is more than a bit different from yours.

 

There is also the Report Writing Interface in the Data step if your data does not require any summarizing that lets you do lots of obnoxious things that the basic report procedures are not set up to handle. But the flexibility comes with a learning curve.

Cynthia_sas
SAS Super FREQ

Hi,

  @ballardw was correct, you can't really get the headers that way you show in the desired output. The way that @ballardw shows them is what PROC REPORT does. As far as PROC REPORT is concerned, the column headers should come first and then the values for the variable in the COMPUTE block.

  The Report Writing Interface, may be the only way to do it, but it still looks odd to me to have one value above the column headers and the other values below.

 

cynthia

shawn123
Obsidian | Level 7
Thank you for the reply!
shawn123
Obsidian | Level 7
Thank you so much!

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
  • 6 replies
  • 2720 views
  • 0 likes
  • 3 in conversation