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

I have headers with extra lines showing below them in PROC REPORT. What is causing this to happen?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ


Hi:

  PROC REPORT will only blank out a header row if EVERY cell on the row is blank. Since you define 'Visit' on the DEFINE statement, but blank out everything else, the string for VISIT header takes up the second row, but the rest of the row headers have all been blanked out. There are 2 ways to fix this. Example 1 replicates the behavior that you described (using slightly revised data from SASHELP.SHOES). Example 2 and Example 3 show the two methods to get rid of the extra line.

  The attached screen shot shows 1 and 2 reports. You'll have to run the code to see #3 behavior as an alternative to #2.

cynthia

data abc;
  set sashelp.shoes;
  where region = 'Canada' and
       ( product contains('Dress') or
        product contains ('Casual'));
  v=region;
  if scan(product,1,' ') = "Men's" then parm = 'One';
  else parm = 'Two';
  if scan(product,2,' ') = 'Dress' then ts = 'Wombat';
  else ts = 'Koala';
  value = sales;
run;

    

ods listing close;
ods html file='c:\temp\extra_line.html' style=sasweb;
proc report data = abc nowd missing nocompletecols;
title '1) Original Report With "extra" line under headers';
footnote 'The Footnote';

    column v parm ts,value;
    define v/ group order=internal 'Visit'  
                       style(column)={font_weight=bold cellwidth=1.50in just=l}
                       style(header)={just=l};
    define parm      / group order=internal ' '
                       style(header)={font_weight=bold just=l};
    define ts / across order=internal ' '  
                       style(column)={just=r};
    define value     / sum '' 
        style(column)={cellwidth=1.30in just=r};
 
    compute after / style={font_size=10pt};
        line "???";
        line "compute after footnote";
  endcomp;
run;

    

proc report data = abc nowd missing nocompletecols;
** move header for VISIT onto COLUMN statement;
** so REPORT receives an entire blank row, which it will suppress;
title '2) Revised Report WithOUT "extra" line under headers';
footnote 'The Footnote';

    column ('Visit' v) parm ts,value;
    define v/ group order=internal ' '  
                       style(column)={font_weight=bold cellwidth=1.50in just=l}
                       style(header)={just=l};
    define parm      / group order=internal ' '
                       style(header)={font_weight=bold just=l};
    define ts / across order=internal ' '  
                       style(column)={just=r};
    define value     / sum '' 
        style(column)={cellwidth=1.30in just=r};
 
    compute after / style={font_size=10pt};
        line "???";
        line "compute after footnote";
  endcomp;
run;


        

proc report data = abc nowd missing nocompletecols;
** put the ACROSS variable "under" the numeric variable;
** so the entire row above the ACROSS variable is blank;
** so REPORT receives an entire blank row, which it will suppress;
title '3) Alternate Revised Report WithOUT "extra" line under headers';
footnote 'The Footnote';

    column v parm value,ts;
    define v/ group order=internal 'Visit'  
                       style(column)={font_weight=bold cellwidth=1.50in just=l}
                       style(header)={just=l};
    define parm      / group order=internal ' '
                       style(header)={font_weight=bold just=l};
    define ts / across order=internal ' '  
                       style(column)={just=r};
    define value     / sum '' 
        style(column)={cellwidth=1.30in just=r};
 
    compute after / style={font_size=10pt};
        line "???";
        line "compute after footnote";
  endcomp;
run;

title;
ods html close;


get_rid_extra_line.png

View solution in original post

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:

  What would be really useful would be if you could illustrate your extra header line issue by coding an example that produces the extra header line, using SASHELP.CLASS or SASHELP.SHOES. That way you would only need to post code that anyone could run (since we all have the SASHELP datasets).

  Without seeing what code you are using, my guess would be that either you are blanking out a header in the wrong place, causing an extra line to be created; or you have used a slash (/) in your header (since the slash is the default "split" character for PROC REPORT headers); or you are using COLUMN spanning headers in the COLUMN statement, mixed with blanking out headers; or you are using ACROSS items and getting some blank lines under the ACROSS headers. So, as you see, there are too many possible scenarios to keep guessing or provide a constructive suggestion for fixing.

  Can you post a (simplifed) example of the code that is causing the problem?

cynthia

Doug
Calcite | Level 5


proc report data = abc nowd missing nocompletecols;
    column v parm ts,value;

    define v/ group order=internal 'Visit' f=v_safxx.
                       style(column)={font_weight=bold cellwidth=1.50in just=l} style(header)={just=l};
    define parm      / group order=internal ' ' format=parm.
                       style={font_weight=bold just=l};
    define ts / across order=internal ' ' f=stat.
                       style={just=r /*posttext=" "*/};
    define value     / sum '' f=nfmt.
        style={cellwidth=1.30in just=r /*posttext=" "*/};
 
    compute after / style= {font_size=2.5};
        line "???";
line "footnotes";

  endcomp;
run;

Cynthia_sas
SAS Super FREQ


Hi:

  PROC REPORT will only blank out a header row if EVERY cell on the row is blank. Since you define 'Visit' on the DEFINE statement, but blank out everything else, the string for VISIT header takes up the second row, but the rest of the row headers have all been blanked out. There are 2 ways to fix this. Example 1 replicates the behavior that you described (using slightly revised data from SASHELP.SHOES). Example 2 and Example 3 show the two methods to get rid of the extra line.

  The attached screen shot shows 1 and 2 reports. You'll have to run the code to see #3 behavior as an alternative to #2.

cynthia

data abc;
  set sashelp.shoes;
  where region = 'Canada' and
       ( product contains('Dress') or
        product contains ('Casual'));
  v=region;
  if scan(product,1,' ') = "Men's" then parm = 'One';
  else parm = 'Two';
  if scan(product,2,' ') = 'Dress' then ts = 'Wombat';
  else ts = 'Koala';
  value = sales;
run;

    

ods listing close;
ods html file='c:\temp\extra_line.html' style=sasweb;
proc report data = abc nowd missing nocompletecols;
title '1) Original Report With "extra" line under headers';
footnote 'The Footnote';

    column v parm ts,value;
    define v/ group order=internal 'Visit'  
                       style(column)={font_weight=bold cellwidth=1.50in just=l}
                       style(header)={just=l};
    define parm      / group order=internal ' '
                       style(header)={font_weight=bold just=l};
    define ts / across order=internal ' '  
                       style(column)={just=r};
    define value     / sum '' 
        style(column)={cellwidth=1.30in just=r};
 
    compute after / style={font_size=10pt};
        line "???";
        line "compute after footnote";
  endcomp;
run;

    

proc report data = abc nowd missing nocompletecols;
** move header for VISIT onto COLUMN statement;
** so REPORT receives an entire blank row, which it will suppress;
title '2) Revised Report WithOUT "extra" line under headers';
footnote 'The Footnote';

    column ('Visit' v) parm ts,value;
    define v/ group order=internal ' '  
                       style(column)={font_weight=bold cellwidth=1.50in just=l}
                       style(header)={just=l};
    define parm      / group order=internal ' '
                       style(header)={font_weight=bold just=l};
    define ts / across order=internal ' '  
                       style(column)={just=r};
    define value     / sum '' 
        style(column)={cellwidth=1.30in just=r};
 
    compute after / style={font_size=10pt};
        line "???";
        line "compute after footnote";
  endcomp;
run;


        

proc report data = abc nowd missing nocompletecols;
** put the ACROSS variable "under" the numeric variable;
** so the entire row above the ACROSS variable is blank;
** so REPORT receives an entire blank row, which it will suppress;
title '3) Alternate Revised Report WithOUT "extra" line under headers';
footnote 'The Footnote';

    column v parm value,ts;
    define v/ group order=internal 'Visit'  
                       style(column)={font_weight=bold cellwidth=1.50in just=l}
                       style(header)={just=l};
    define parm      / group order=internal ' '
                       style(header)={font_weight=bold just=l};
    define ts / across order=internal ' '  
                       style(column)={just=r};
    define value     / sum '' 
        style(column)={cellwidth=1.30in just=r};
 
    compute after / style={font_size=10pt};
        line "???";
        line "compute after footnote";
  endcomp;
run;

title;
ods html close;


get_rid_extra_line.png
Doug
Calcite | Level 5

Thank you the suggested solutions worked!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2598 views
  • 1 like
  • 2 in conversation