The SAS Output Delivery System and reporting techniques

Add Horizontal line

Reply
Contributor sks
Contributor
Posts: 42

Add Horizontal line

Hello,
I am using proc report and I have a block oftext that I am displaying using the line statement. I need to enter a horizontal line after the text. Can someone guide me on how this can be accomplished.


For ex
this is my block if text
____________________________________________________________________


Thanks
Shri
SAS Super FREQ
Posts: 8,868

Re: Add Horizontal line

Hi:
It depends on your destination of interest. If you are using ODS HTML, then you could use HTML tags like <u> in the LINE statement. But you would also have to use PROTECTSPECIALCHARS=OFF to remove the normal protection for < and > symbols. If you want ODS PDF, then you can use the textdecoration style attribute to do underlining; if you want ODS RTF, then you can use RTF control strings to do underlining. If you want LISTING output, then you just write a line of dashes ( - ) or underscores ( _ ) with another LINE statement.

What is your destination of interest??

cynthia
SAS Super FREQ
Posts: 8,868

Re: Add Horizontal line

Hi:
For some reason I spaced out on the fact that in SAS 9.2, TextDecoration works for all the major destinations.

cynthia
[pre]

ods html file='c:\temp\underline_td.html' style=sasweb;
ods rtf file='c:\temp\underline_td.rtf';
ods pdf file='c:\temp\underline_td.pdf' ;

proc report data=sashelp.class(obs=2) nowd;
title "2) Using TEXTDECORATION style attribute";
column name age height weight;
compute after /
style={textdecoration=underline};
line 'This is an underlined line.';
endcomp;
run;

ods _all_ close;
[/pre]
Contributor sks
Contributor
Posts: 42

Re: Add Horizontal line

Posted in reply to Cynthia_sas
Cynthia,
Thank you for your response. I do have one question though, does the underline only underline the text or can I get a line for the entire page width.


Thanks
Shri
Super Contributor
Super Contributor
Posts: 3,174

Re: Add Horizontal line

After executing the example code, it's clear that only the text is underlined.

Consider using a FOOTNOTE statement with underscore character repeated.

Scott Barry
SBBWorks, Inc.
SAS Super FREQ
Posts: 8,868

Re: Add Horizontal line

Hi:
I don't understand your question. The LINE statement in PROC REPORT "lives" within the boundary of the report table that is built by PROC REPORT. So, for example, if you have only 5 columns on your report, it is unlikely that the PROC REPORT table will be as wide as the width of the physical page. So, in this case, the answer is NO, if you are underlining text from a LINE statement, the text (using textdecoration style attribute) only underlines the text string. Other methods do exist for putting lines into the document - -but several of them are destination specific.

You still have not said what your destination of interest is. If, for example, you were interested in the RTF destination, there is a way (in addition to Scott's suggestion) to underline the entire width of the page (such as for a TITLE or FOOTNOTE statement). But title and footnote text would not come from a LINE statement. So, I'm confused about what you want -- text from a LINE statement to be underlined or an "extra" line someplace else on the report -- but not from a LINE statement.

So, what is your destination of interest?? HTML, RTF, PDF? And are you writing text with a LINE statement or do you want a line above your title or footnote text??? Or to put it another way, can you explain what the line is for and why it needs to span from margin to margin and not from table edge to table edge??

cynthia
Contributor sks
Contributor
Posts: 42

Re: Add Horizontal line

Posted in reply to Cynthia_sas
> Hi:
> I don't understand your question. The LINE
> statement in PROC REPORT "lives" within the boundary
> of the report table that is built by PROC REPORT.
> So, for example, if you have only 5 columns on your
> report, it is unlikely that the PROC REPORT table
> will be as wide as the width of the physical page.
> So, in this case, the answer is NO, if you are
> underlining text from a LINE statement, the text
> (using textdecoration style attribute) only
> underlines the text string. Other methods do exist
> for putting lines into the document - -but several
> of them are destination specific.
>
> You still have not said what your destination of
> interest is. If, for example, you were interested in
> the RTF destination, there is a way (in addition to
> Scott's suggestion) to underline the entire width of
> the page (such as for a TITLE or FOOTNOTE
> statement). But title and footnote text would not
> come from a LINE statement. So, I'm confused about
> what you want -- text from a LINE statement to be
> underlined or an "extra" line someplace else on the
> report -- but not from a LINE statement.
>
> So, what is your destination of interest?? HTML,
> RTF, PDF? And are you writing text with a LINE
> statement or do you want a line above your title or
> footnote text??? Or to put it another way, can you
> explain what the line is for and why it needs to
> span from margin to margin and not from table edge
> to table edge??
>

Cynthia,
Thank you for your response. To answer your questions, the destination is PDF and the I am writing text with a line statement and the text is not the header or the footnote. The text is below the title and is more like the description about the report. Essentially what I have to do is put a line on top and below the description text (more like a box to cover the descritpion but with no lines on the left and right) Does this explain a little more on what I am trying to do. Right now I am using the following statement if the text is outside a if condition block

line 160*"~S={font_weight=bold just=left font_size=11pt}~{Super _}";

and
text1=repeat("_",135)
if the text is within a if block(for some reason I could not use line 160*"~S={font_weight=bold just=left font_size=11pt}~{Super _}";
within the if block).

Thanks
Shri
SAS Super FREQ
Posts: 8,868

Re: Add Horizontal line

Hi:
Thanks for the feedback. In RTF, it is fairly easy to underline or overline a text string using the \BRDRB or \BRDRT RTF control strings, but those are not available for PDF. However, you can use the BORDERBOTTOMSTYLE and BORDERBOTTOMCOLOR style attributes with PDF (in SAS 9.2).

Just curious -- are you using the JOURNAL style????

Also about your LINE statement. I believe if you look in the PROC REPORT doc,
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473628.htm

you will find this restriction -- very clearly explained:


Restriction: You cannot use the LINE statement in conditional statements (IF-THEN, IF-THEN/ELSE, and SELECT) because it is not executed until PROC REPORT has executed all other statements in the compute block.


Here's an example of using RTF control strings in contrast to the use of BORDERBOTTOMSTYLE and BORDERBOTTOMCOLOR style attributes for PDF (instead of the superscript or repeating underscores).

cynthia

[pre]
ods pdf file='c:\temp\underline_borderbottom.pdf' style=journal;

proc report data=sashelp.class(obs=2) nowd
style(lines)={just=c font_weight=bold font_size=11pt};
title "1) Using BORDERBOTTOM style attribute";
column name age height weight;
compute before _page_ /
style={borderbottomstyle=solid borderbottomcolor=black};
line '1.1 This is a caption. It says something about the report.';
endcomp;
run;

ods _all_ close;

ods rtf file='c:\temp\underline_RTFcontrol.rtf' style=journal;

proc report data=sashelp.class(obs=2) nowd
style(lines)={protectspecialchars=off just=c
font_size=11pt font_weight=bold};
title "2) With RTF Control Strings";
column name age height weight;
compute before _page_ /
style={pretext='\brdrb\brdrs\w1 '} ;
line '2.1 This is a caption. It says something about the report.';
endcomp;
run;

ods _all_ close;
[/pre]
Contributor sks
Contributor
Posts: 42

Re: Add Horizontal line

Posted in reply to Cynthia_sas
Cynthia,
I looked at your response and tried to implement it but I don't think the line is showing up. Also my issue is that this description only needs to come in the first page and not in the subsequent pages. Any idea if this can be done

Thanks
Shri
SAS Super FREQ
Posts: 8,868

Re: Add Horizontal line

Hi:
You said "I don't think the line is showing up." This seems to me to be a binary situation -- either the line IS showing up or it is NOT.

Reasons that BORDERBOTTOM... might not work or appear to work
1) you are using SAS 9.1 (As I said, you need at least SAS 9.2 for the BORDERBOTTOM...to work). My code, run on SAS 9.2 Phase 2 version, as posted, does produce a line underneath the caption.
2) you are NOT using the JOURNAL style (in order to see BORDERBOTTOM, all the other interior table lines much be turned off -- such as they are in the JOURNAL style) For example, if I run my code using the DEFAULT style for PDF = STYLES.PRINTER -- then there is no underline to see.
3) your PDF file is zoomed so small that thin lines sometimes disappear (if you increase the ZOOM level to 100%, usually "missing" lines suddenly appear
4) you have errors in the SAS log that you are not sharing
5) there is some other error.

You also said you do not like the placement of COMPUTE BEFORE _PAGE_ (on EVERY PAGE). That is a different issue -- you could do a simple:
[pre]
compute before /
style={borderbottomstyle=solid borderbottomcolor=black};
line '3.1 This is a caption. It says something about the report.';
endcomp;
[/pre]

But the placement of the LINE text with COMPUTE BEFORE is different than it is with COMPUTE BEFORE _PAGE_ and you may not like the change in placement...although you will only get the LINE text on the first page.

Or, alternately, you could have 2 PROC REPORT steps -- 1 step to produce the observations on page 1 -- with the caption and then a second step using FIRSTOBS= to produce all subsequent pages without the caption.

After those suggestions, I'm out of ideas.

cynthia
Respected Advisor
Posts: 3,799

Re: Add Horizontal line

> Also my
> issue is that this description only needs to come in
> the first page and not in the subsequent pages. Any
> idea if this can be done

Consider Cynthia's example with these modifications to the COMPUTE block.

[pre]
ods pdf file='underline_borderbottom.pdf' style=journal;
title "1) Using BORDERBOTTOM style attribute";
proc report data=sashelp.class nowd
style(lines)={just=c font_weight=bold font_size=11pt};

column sex name age height weight;
define sex / order;
break before sex / page;
compute before _page_ /
style={borderbottomstyle=solid borderbottomcolor=black};
i + 1;
text = '2.1 This is a caption. It says something about the report.';
if i gt 1
then l=0;
else l=length(text);
line text $varying200. l;
endcomp;
run;
ods pdf close;

ods rtf file='underline_RTFcontrol.rtf' style=journal;
title "2) With RTF Control Strings";
proc report data=sashelp.class nowd
style(lines)={protectspecialchars=off just=c
font_size=11pt font_weight=bold};

column sex name age height weight;
define sex / order;
break before sex / page;
compute before _page_ / style={pretext='\brdrb\brdrs\w1 '} ;
i + 1;
text = '2.1 This is a caption. It says something about the report.';
if i gt 1
then l=0;
else l = length(text);
line text $varying200. l;
endcomp;
run;
ods rtf close;
[/pre]
SAS Super FREQ
Posts: 8,868

Re: Add Horizontal line

Posted in reply to data_null__
Thank you! That is one more idea. Length of 0 with $varying did not get into my list!

cynthia
Ask a Question
Discussion stats
  • 11 replies
  • 2886 views
  • 0 likes
  • 4 in conversation