Help using Base SAS procedures

How to control the rules of proc report ...

Reply
Contributor
Posts: 30

How to control the rules of proc report ...

Hi,

   I use proc report to produce a report of my data. I used

   Style(report)={font_size=0.5 background=white just=center frame=void rules=rows cellpadding=1pt cellspacing=0.0pt borderwidth=0.1pt}

   I have two layers group variables, one is country and the next is state. My report has lines under every state. What I want is only lines for each country, such as below:

I want below:

_____________________________

  Courty A STA

                  STB

-------------------------------------------------

CountryB STA

                 STB

-------------------------------------------------

NOT as below:

-------------------------------------------------

CountryA STA

-------------------------------------------------

                STB

-------------------------------------------------

CountryB STA

------------------------------------------------

                 STB

------------------------------------------------

      How can I achive this? Thanks.

Jian

SAS Employee
Posts: 232

Re: How to control the rules of proc report ...

Hi there - I have moved your post to the SAS Procedures community for increased visibility

SAS Super FREQ
Posts: 8,743

Re: How to control the rules of proc report ...

Hi:

  To a certain extent, the destination that you choose will determine how the interior lines are displayed. And, remember that the overrides that you are specifying in your STYLE(REPORT) option are actually overriding what is set by the style template. So without seeing more of your code, the ODS destination and the style you are using, it is very hard to help you and make a constructive comment.

  Also, saying that you have two "layers" of group variables doesn't quite mean to me, what it seems to mean to you. Seeing ALL of your PROC REPORT code would be very helpful. In addition, you post output, but the output from PROC REPORT is highly dependent on the structure of the INPUT data. Can you also post some data for testing or replicate your report using one of the SASHELP datasets, so that other people can easily copy and run the code??

  For example, if you run this code, which has 2 nested GROUP usage items (REGION and PRODUCT), you will see that each destination handles the interior table lines differently. I always find it useful to understand the default behavior before I try any overrides. So #1 shows the default behavior with SPANROWS and no other change. #2 report shows your single line of code but without spanrows option and #3 adds the spanrows option back in.  I only show 3 destinations and the default style for each destination. Your output could be impacted by the style you chose, the destination you chose and the other statements in your PROC REPORT code.

Cynthia

ods rtf file='c:\temp\testlines.rtf' style=styles.rtf;

ods pdf file='c:\temp\testlines.pdf' style=styles.printer;

ods html file='c:\temp\testlines.html' style=styles.htmlblue;

       

title '1) Default Behavior with Spanrows, no overrides';

proc report data=sashelp.shoes nowd spanrows;

  where region in ('Asia', 'Canada');

  column region product sales inventory returns;

  define region / group;

  define product / group;

  define sales / sum;

  define inventory / sum;

  define returns / sum;

  rbreak after /summarize;

run;

  

title '2) Example from Forum Question';

proc report data=sashelp.shoes nowd

     Style(report)={font_size=0.5 background=white just=center

                    frame=void rules=rows cellpadding=1pt cellspacing=0.0pt borderwidth=0.1pt};

  where region in ('Asia', 'Canada');

  column region product sales inventory returns;

  define region / group;

  define product / group;

  define sales / sum;

  define inventory / sum;

  define returns / sum;

  rbreak after /summarize;

run;

      

title '3) Example with Override and with Spanrows';

proc report data=sashelp.shoes nowd spanrows

     Style(report)={font_size=0.5 background=white just=center

                    frame=void rules=rows cellpadding=1pt cellspacing=0.0pt borderwidth=0.1pt};

  where region in ('Asia', 'Canada', 'Pacific');

  column region product sales inventory returns;

  define region / group;

  define product / group;

  define sales / sum;

  define inventory / sum;

  define returns / sum;

  rbreak after /summarize;

run;

ods _all_ close;

Super User
Posts: 9,681

Re: How to control the rules of proc report ...

How does it look ?

ods pdf file='c:\temp\testlines.pdf' style=styles.printer;
proc report data=sashelp.shoes nowd spanrows
     Style(report)={font_size=0.5 background=white just=center
                    frame=void rules=none cellpadding=1pt cellspacing=0.0pt borderwidth=0.1pt};
  where region in ('Asia', 'Canada', 'Pacific');
  column region product sales inventory returns;
  define region / group;
  define product / group;
  define sales / sum;
  define inventory / sum;
  define returns / sum;
  compute after region/style(lines)={font_size=2pt background=grayaa};
line ' ' ;
endcomp;
  rbreak after /summarize;
run;
ods pdf close;

Xia Keshan

Contributor
Posts: 30

Re: How to control the rules of proc report ...

It works. Thanks.

Ask a Question
Discussion stats
  • 4 replies
  • 182 views
  • 0 likes
  • 4 in conversation