Help using Base SAS procedures

Extra Line PROC Report

Accepted Solution Solved
Reply
Contributor
Posts: 53
Accepted Solution

Extra Line PROC Report

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


Accepted Solutions
Solution
‎07-13-2012 11:10 PM
SAS Super FREQ
Posts: 8,743

Re: Extra Line PROC Report


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


All Replies
SAS Super FREQ
Posts: 8,743

Re: Extra Line PROC Report

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

Contributor
Posts: 53

Re: Extra Line PROC Report


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;

Solution
‎07-13-2012 11:10 PM
SAS Super FREQ
Posts: 8,743

Re: Extra Line PROC Report


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
Contributor
Posts: 53

Re: Extra Line PROC Report

Thank you the suggested solutions worked!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 800 views
  • 1 like
  • 2 in conversation