BookmarkSubscribeRSS Feed
jzhang332002
Fluorite | Level 6

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

4 REPLIES 4
Community_Help
SAS Employee

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

Cynthia_sas
SAS Super FREQ

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;

Ksharp
Super User

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

jzhang332002
Fluorite | Level 6

It works. Thanks.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1073 views
  • 0 likes
  • 4 in conversation