The SAS Output Delivery System and reporting techniques

proc report and column header

Reply
N/A
Posts: 0

proc report and column header

I saw an earlier post that adivised using 'noheader' when one does not want to output the column header.
I would like to output some column headers but not others. If I use 'noheader', then all headers are supressed.
Would anyone please show me how I may suppress some column headers but not others?
Contributor
Posts: 74

Re: proc report and column header

Posted in reply to deleted_user
dont know how you do it. assume you use proc report / column / define. you can specify ' ' to the variable you dont want the header after defining the column variable.
SAS Super FREQ
Posts: 8,868

Re: proc report and column header

Posted in reply to deleted_user
Hi:
You are correct, NOHEADER in PROC REPORT suppresses all headers, by design.

However, if you only want to suppress one or two headers, you can accomplish that in the DEFINE statement for your variable or report item, as shown in the code below,
where the ' ' (quote space quote) as a label suppresses the header for SEX and WEIGHT.

cynthia
[pre]
ods html file='colhdr.html' style=sasweb;
ods rtf file='colhdr.rtf' style=journal;
ods pdf file='colhdr.pdf';

proc report data=sashelp.class nowd;
column name sex age height weight;
define name / order 'Name';
define sex / display ' ';
define age / display 'Age';
define height / display 'Height';
define weight / display ' ';
run;

ods _all_ close;
[/pre]
N/A
Posts: 0

Re: proc report and column header

Posted in reply to deleted_user
Thank you both for the response. I tried the ' ' in the define statement earlier and got a warning message.
__________________________________________________________________
WARNING: Use of CELLWIDTH/OUTPUTWIDTH= in a spanning header or footer will rarely yield expected results. For conventional usage, specify outputwidth only for
the data column cells.
____________________________________________________________________

This is the code that I used, perhaps I can't do it for the two id vars together?

proc report missing nowindows data = &dsin split = "#"
style(report) = [asis = off
rules = groups
cellspacing = 0
cellpadding = 0pt
protectspecialchars=off
]
style(header column)=[asis=off protectspecialchars=off rules=groups];

column section statnm v0 v1 v2 v3 v6 v9 v12
v16 v20 v24 v30 v36 v42 v48
v54 v60 v66 v72 v78 v84 v90
v96 v102 v108 %if &subset eq %then v114 ; v999;

define section / order style=[just=center cellwidth=22%] ' ' id;
define statnm / order style=[just=center cellwidth=8%] ' ' id;
define v0 / display style=[just=center cellwidth=10%] "Baseline in # 016.0012{\super a} # N = &bl";
define v1 / display style=[just=center cellwidth=10%] "Month 1 in # 20021623{\super b} # N = &m1";
define v2 / display style=[just=center cellwidth=8%] "Month 2 # N = &m2";
define v3 / display style=[just=center cellwidth=8%] "Month 3 # N = &m3";
define v6 / display style=[just=center cellwidth=8%] "Month 6 # N = &m6";
define v9 / display style=[just=center cellwidth=8%] "Month 9 # N = &m9";
define v12 / display style=[just=center cellwidth=8%] "Month 12 # N = &m12";

define v16 / display style=[just=center cellwidth=8%] "Month 16 # N = &m16" page;
define v20 / display style=[just=center cellwidth=8%] "Month 20 # N = &m20";
define v24 / display style=[just=center cellwidth=8%] "Month 24 # N = &m24";
define v30 / display style=[just=center cellwidth=8%] "Month 30 # N = &m30";
N/A
Posts: 0

Re: proc report and column header

Posted in reply to deleted_user
When I tried just use one quoted space for either ID variable, there is no warning message. But when I have the quoted space for both ID variables, I got the aforementioned warning....
SAS Super FREQ
Posts: 8,868

Re: proc report and column header

Posted in reply to deleted_user
Hi:
The message has nothing to do with the use of ' ' for the ID items. If you review the program in the SAS log (shown #1 below), you can see that I have used ' ' for both ID items without any messages.

I'm also not sure what you're trying to do with the PAGE option, however, this option will work differently for ODS destinations than it does for the LISTING destination, as described here:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473627.htm#a003072105


In listing destinations, a PAGE option on the DEFINE statement causes PROC REPORT to print this column and all columns to its right on a new page. However, for ODS MARKUP, HTML, PRINTER , and RTF destinations, the page break doesn't occur until all the rows in the report have been printed. Therefore, PROC REPORT prints all the rows for all the columns to the left of the PAGE column and then starts over at the top of the report and prints the PAGE column and the columns to the right.


The message is complaining about an incorrect usage of cellwidth. I believe it's happening because you have the incorrect syntax for the STYLE= override -- usually, PROC REPORT won't complain, but in this case, I believe you're getting the WARNING message because when ODS tries to calculate the proper widths, it doesn't know which table element (header or column) you intend to alter with your STYLE= syntax. If you look at the #2 program in the SAS log, you will see that I can duplicate your warning message with the same incorrect usage.

With PROC REPORT, the usual syntax for STYLE= overrides is:
style(header)={attribute=value} OR
style(column)={attribute=value}
...and, in fact, if I alter my code to use this form of STYLE override, the warning message disappears (as shown #3 LOG below).

cynthia

#1 program LOG shows that you can use ' ' on DEFINE with ID;
[pre]

1985 ods html file='blank_id.html' style=sasweb;
NOTE: Writing HTML Body file: blank_id.html
1986 ods rtf file='blank_id.rtf' style=journal;
NOTE: Writing RTF Body file: blank_id.rtf
1987 ods pdf file='blank_id.pdf';
NOTE: Writing ODS PDF output to DISK destination "C:\temp\blank_id.pdf", printer "PDF".
1988
1989 proc report data=sashelp.class nowd;
1990 column name sex age height weight;
1991 define name / id display ' ';
1992 define sex / id display ' ';
1993 define age / display 'Age';
1994 define height / display 'Ht';
1995 define weight / display 'Wt';
1996 run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.18 seconds
cpu time 0.06 seconds


1997 ods _all_ close;

[/pre]

#2: However, I CAN duplicate your WARNING message by altering the program as shown below:
[pre]
2002 ods html file='dup_msg.html' style=sasweb;
NOTE: Writing HTML Body file: dup_msg.html
2003 ods rtf file='dup_msg.rtf' style=journal;
NOTE: Writing RTF Body file: dup_msg.rtf
2004 ods pdf file='dup_msg.pdf';
NOTE: Writing ODS PDF output to DISK destination "C:\temp\dup_msg.pdf", printer "PDF".
2005
2006 proc report data=sashelp.class nowd;
2007 column name sex age height weight;
2008 define name / id display ' ' style=[cellwidth=25%] ;
2009 define sex / id display ' ' style=[cellwidth=25%] ;
2010 define age / display 'Age' style=[cellwidth=25%] ;
2011 define height / display 'Ht' style=[cellwidth=25%] ;
2012 define weight / display 'Wt' style=[cellwidth=20%] ;
2013 run;

WARNING: Use of CELLWIDTH/OUTPUTWIDTH= in a spanning header or footer will rarely yield
expected results. For conventional usage, specify outputwidth only for the data
column cells.
WARNING: Use of CELLWIDTH/OUTPUTWIDTH= in a spanning header or footer will rarely yield
expected results. For conventional usage, specify outputwidth only for the data
column cells.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.18 seconds
cpu time 0.07 seconds


2014 ods _all_ close;

[/pre]


#3: Note that with correct syntax for STYLE override there is no warning in the LOG:
[pre]
2019 ods html file='no_msg.html' style=sasweb;
NOTE: Writing HTML Body file: no_msg.html
2020 ods rtf file='no_msg.rtf' style=journal;
NOTE: Writing RTF Body file: no_msg.rtf
2021 ods pdf file='no_msg.pdf';
NOTE: Writing ODS PDF output to DISK destination "C:\temp\no_msg.pdf", printer "PDF".
2022
2023 proc report data=sashelp.class nowd;
2024 column name sex age height weight;
2025 define name / id display ' ' style(column)=[cellwidth=25%] ;
2026 define sex / id display ' ' style(column)=[cellwidth=25%] ;
2027 define age / display 'Age' style(column)=[cellwidth=25%] ;
2028 define height / display 'Ht' style(column)=[cellwidth=25%] ;
2029 define weight / display 'Wt' style(column)=[cellwidth=20%] ;
2030 run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.17 seconds
cpu time 0.06 seconds


2031 ods _all_ close;

[/pre]
N/A
Posts: 0

Re: proc report and column header

Posted in reply to Cynthia_sas
Cynthia, Once I use the correct style statement, i.e., style(column)=[cellwidth=...]; the warning messages disappeared. It seems the log only complains when one uses a blank label (quoted space) in two adjacent columns.

In terms of the 'page' option on the define statement, I have more than 3 dozens or so columns but only one row of data on this table. Therefore, I am using 'page' option to start a new page every few columns with the 'id' columns repeating on each page. I am using RTF destination.

I also noticed that while the SAS titles are printed on every page, the footnotes only printed at the end of the last page. I am using Title and Footnote statement. I submitted a question to SAS Support via email.

Perhaps you can shed some light on this one as well?

I truly appreciate your advice.
SAS Super FREQ
Posts: 8,868

Re: proc report and column header

Posted in reply to deleted_user
Hi:
Not sure what you mean by "It seems the log only complains when one uses a blank label (quoted space) in two adjacent columns."

In this code (shown in the SAS log), I have 3 adjacent columns with a blank label and there are no complaints in the log:
[pre]
255 ods rtf file='blnk_hdr.rtf';
NOTE: Writing RTF Body file: blnk_hdr.rtf
256
257 proc report data=sashelp.class nowd;
258 column name age sex height weight;
259 define name / order ' ';
260 define age /display ' ';
261 define height / display ' ';
262 define sex / display 'Gender';
263 define weight / display ' ';
264 run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.06 seconds
cpu time 0.04 seconds


265
266 ods rtf close;

[/pre]

As I said, I believe your issue was wholly with CELLWIDTH and did not have anything to do with blank labels.

About your other question -- regarding SAS Titles and Footnotes. I don't observe that behavior -- if I create a dataset with one row and 65 columns and then use your technique (multiple 'PAGE' options on my DEFINE statements), I see a footnote on every RTF page. So there must be something else going on in your code. Tech Support is probably your best resource on this question.

cynthia
N/A
Posts: 0

Re: proc report and column header

Posted in reply to Cynthia_sas
Hi Cynthia,
What I meant is that the cellwidth with ambiguous style statement only produces warning when two columns are defined with blank labels. In example 1 and 3, no warning message is produced. In example 2, the warning message is produced by SAS.

Thanks,

535 /*Example 1: One ambiguous style statement with blank label*/
536 proc report missing nowindows data = &dsin split = "#"
537 style(report) = [asis = off
538 rules = groups
The SAS System

539 cellspacing = 0
540 cellpadding = 0pt
541 protectspecialchars=off
542 ]
543 style(header column)=[asis=off protectspecialchars=off rules=groups];
544
545 column section statnm v0 v1 v2 v3 v6 v9 v12 ;
546
547 define section / order style=[just=center cellwidth=22%] 'Hi ' ;
548 define statnm / order style=[just=center cellwidth=8%] ' ' ;
549 define v0 / display style=[just=center cellwidth=10%] "Baseline in # 016.0012{\super a} # N = &bl";
550 define v1 / display style=[just=center cellwidth=10%] "Month 1 in # 20021623{\super b} # N = &m1";
551 define v2 / display style=[just=center cellwidth=8%] "Month 2 # N = &m2";
552 define v3 / display style=[just=center cellwidth=8%] "Month 3 # N = &m3";
553 define v6 / display style=[just=center cellwidth=8%] "Month 6 # N = &m6";
554 define v9 / display style=[just=center cellwidth=8%] "Month 9 # N = &m9";
555 define v12 / display style=[just=center cellwidth=8%] "Month 12 # N = &m12";
556
557 compute before section;
558 line @1 ' ';
559 endcomp;
560 run;

NOTE: Multiple concurrent threads will be used to summarize data.
NOTE: There were 1 observations read from the data set WORK.T_ALL.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.00 seconds
cpu time 0.08 seconds


561
562 /*Example 2: Two ambiguous style statement with blank label*/
563 proc report missing nowindows data = &dsin split = "#"
564 style(report) = [asis = off
565 rules = groups
566 cellspacing = 0
567 cellpadding = 0pt
568 protectspecialchars=off
569 ]
570 style(header column)=[asis=off protectspecialchars=off rules=groups];
571
572 column section statnm v0 v1 v2 v3 v6 v9 v12 ;
573
The SAS System

574 define section / order style=[just=center cellwidth=22%] ' ' ;
575 define statnm / order style=[just=center cellwidth=8%] ' ' ;
576 define v0 / display style=[just=center cellwidth=10%] "Baseline in # 016.0012{\super a} # N = &bl";
577 define v1 / display style=[just=center cellwidth=10%] "Month 1 in # 20021623{\super b} # N = &m1";
578 define v2 / display style=[just=center cellwidth=8%] "Month 2 # N = &m2";
579 define v3 / display style=[just=center cellwidth=8%] "Month 3 # N = &m3";
580 define v6 / display style=[just=center cellwidth=8%] "Month 6 # N = &m6";
581 define v9 / display style=[just=center cellwidth=8%] "Month 9 # N = &m9";
582 define v12 / display style=[just=center cellwidth=8%] "Month 12 # N = &m12";
583
584 compute before section;
585 line @1 ' ';
586 endcomp;
587 run;

NOTE: Multiple concurrent threads will be used to summarize data.
WARNING: Use of CELLWIDTH/OUTPUTWIDTH= in a spanning header or footer will rarely yield expected results. For conventional usage, specify outputwidth only for
the data column cells.
NOTE: There were 1 observations read from the data set WORK.T_ALL.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.00 seconds
cpu time 0.04 seconds


588
589 /*Example 3: All ambiguous style statement without blank label*/
590 proc report missing nowindows data = &dsin split = "#"
591 style(report) = [asis = off
592 rules = groups
593 cellspacing = 0
594 cellpadding = 0pt
595 protectspecialchars=off
596 ]
597 style(header column)=[asis=off protectspecialchars=off rules=groups];
598
599 column section statnm v0 v1 v2 v3 v6 v9 v12 ;
600
601 define section / order style=[just=center cellwidth=22%] 'Hi ' ;
602 define statnm / order style=[just=center cellwidth=8%] 'OK ' ;
603 define v0 / display style=[just=center cellwidth=10%] "Baseline in # 016.0012{\super a} # N = &bl";
604 define v1 / display style=[just=center cellwidth=10%] "Month 1 in # 20021623{\super b} # N = &m1";
605 define v2 / display style=[just=center cellwidth=8%] "Month 2 # N = &m2";
606 define v3 / display style=[just=center cellwidth=8%] "Month 3 # N = &m3";
The SAS System

607 define v6 / display style=[just=center cellwidth=8%] "Month 6 # N = &m6";
608 define v9 / display style=[just=center cellwidth=8%] "Month 9 # N = &m9";
609 define v12 / display style=[just=center cellwidth=8%] "Month 12 # N = &m12";
610
611 compute before section;
612 line @1 ' ';
613 endcomp;
614 run;

NOTE: Multiple concurrent threads will be used to summarize data.
NOTE: There were 1 observations read from the data set WORK.T_ALL.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.00 seconds
cpu time 0.05 seconds
SAS Super FREQ
Posts: 8,868

Re: proc report and column header

Posted in reply to deleted_user
Ah, got it. Interesting, but in my opinion, ultimately a moot (and possibly irrelevant) point because that form of the style statement is not the best practice to follow with PROC REPORT. PROC REPORT is MUCH happier when you tell it the report area being impacted by the STYLE= override.

Just because you sometimes get a free pass (no warning) using ambiguous syntax, doesn't mean you should go ahead and use the ambiguous syntax and hope that it will always work. Besides, you want PROC REPORT to be happy, don't you???

(just joking...)
cynthia
N/A
Posts: 0

Re: proc report and column header

Posted in reply to Cynthia_sas
Agreed.

Thank you very much for all your help!
Occasional Contributor
Posts: 14

Re: proc report and column header

Posted in reply to Cynthia_sas

Cynthia,

 

Thanks so much!  This was a huge help to me just now!

 

Cheers,

Mary R.

Ask a Question
Discussion stats
  • 11 replies
  • 900 views
  • 1 like
  • 4 in conversation