The SAS Output Delivery System and reporting techniques

Double line at specific location in proc report

Reply
Occasional Contributor
Posts: 9

Double line at specific location in proc report

[ Edited ]

I am going to add a double line at certain group, but not all group, how can I do that?

here is the dataset

data lines;
input section column1$ column2$ column3$ column4$ column5$;
return;
cards;
1 A B C D E
1 A B C D E
1 A B C D E
1 B C D E F
1 B C D E F
1 C D E F G
2 C D E F G
;
run;

 

program was used:

ods listing close;
ods rtf file = "D:\from desk\example_lines.rtf" style=journal;
proc report data=lines NOWINDOWS
STYLE(report)=[frame=box rules=cols]
style(header)={borderbottomwidth=2pt borderbottomcolor=black};
title '3) Using border lines as a divider';
column section column1 column2 column3 column4 column5;
define section / order order=data noprint;
define column1 / "Column 1";
define column2 / "Column 2";
define column3 / "Column 3";
define column4 / "Column 4";
define column5 / "Column 5";
compute after section /
style={height=1px bordertopcolor=black borderbottomcolor=black cellpadding=0
bordertopstyle=solid borderbottomstyle=solid
bordertopwidth=2pt borderbottomwidth=2pt};
line ' ';
endcomp;
run;
ods _all_ close;

 

Table is attached, which was created by the program above.

 

if just want to create double line at the end of section 1 (supress the double line at section 2), do not need the double line at the end, how can I reach that? Thank you!

 

Attachment
SAS Super FREQ
Posts: 8,642

Re: Double line at specific location in proc report

Hi,

The short answer to your question is that a compute block on a section will produce the SAME style override for EVERY section. You posted your code. It looks like you are interested in RTF output. But the FIG1.JPG you produced does not look like it was produced with this code.

And, since the data you posted doesn't make sense (the last row for section 1 is exactly the same as the first row for section 2), the report you posted looks like it is only 1 section. So it is hard to see what the break for section 2 looks like, since you don't show the break appearing for section 2 (and it should).

Generally, if you want variable information written at a break point (such as changing the style for 1 cell), you can typically do that with a CALL define statement in a COMPUTE block.) However, changing the border lines is typically, not the kind of thing you change on the break.

Also typically at a break between groups, you have some kind of summary line which is written with a BREAK AFTER grpvar / summarize; and then the LINE statement in the COMPUTE block appears underneath that summary line. It was hard to tell whether you intended a summary line or not, since your cells were full of character strings, which is unusual.

But a LINE statement cannot be written conditionally. So if you want to suppress your line statement output for other sections, you will have to use $VARYING with a length of 0 for the sections where you do not want to write the line.

cynthia
Occasional Contributor
Posts: 9

Re: Double line at specific location in proc report

Grand Advisor
Posts: 9,315

Re: Double line at specific location in proc report



data lines;
input section column1$ column2$ column3$ column4$ column5$;
return;
cards;
1 A B C D E
1 A B C D E
1 A B C D E
1 B C D E F
1 B C D E F
1 C D E F G
2 C D E F G
;
run;


ods rtf file = "/folders/myfolders/example_lines.rtf" style=journal;
proc report data=lines NOWINDOWS 
STYLE(report)={frame=box rules=cols}
style(header)={borderbottomwidth=2pt borderbottomcolor=black};
title '3) Using border lines as a divider';
column section column1 column2 column3 column4 column5 section;
define section / order order=data noprint;
define column1 / "Column 1";
define column2 / "Column 2";
define column3 / "Column 3";
define column4 / "Column 4";
define column5 / "Column 5";
compute after section ;
if section=1 then call define(_row_,'style',
'style={height=1px cellpadding=0 bordertopwidth=2pt borderbottomwidth=2pt 
bordertopstyle=solid borderbottomstyle=solid 
bordertopcolor=black borderbottomcolor=black }' );
line ' ';
endcomp;
break after section/summarize;
run;
ods rtf close;
Occasional Contributor
Posts: 9

Re: Double line at specific location in proc report

Thank you! Ksharp,

 

It works, but not perfect, there is too much space at the last row. 

Grand Advisor
Posts: 9,315

Re: Double line at specific location in proc report

OK. I misunderstood what you mean.





data lines;
input section column1$ column2$ column3$ column4$ column5$;
return;
cards;
1 A B C D E
1 A B C D E
1 A B C D E
1 B C D E F
1 B C D E F
1 C D E F G
2 C D E F G
;
run;


ods rtf file = "/folders/myfolders/example_lines.rtf" style=journal;
ods escapechar='~';
proc report data=lines NOWINDOWS 
STYLE(report)={frame=box rules=cols}
style(header)={borderbottomwidth=2pt borderbottomcolor=black};
title '3) Using border lines as a divider';
column section column1 column2 column3 column4 column5 section;
define section / order order=data noprint;
define column1 / "Column 1";
define column2 / "Column 2";
define column3 / "Column 3";
define column4 / "Column 4";
define column5 / "Column 5";
compute after section ;
line=
"~S={height=1px cellpadding=0 bordertopwidth=2pt borderbottomwidth=2pt 
bordertopstyle=solid borderbottomstyle=solid 
bordertopcolor=black borderbottomcolor=black }  " ;
len=0;
if section=1 then len=200;

line line $varying200. len;
endcomp;
run;
ods rtf close;

Occasional Contributor
Posts: 9

Re: Double line at specific location in proc report

Hi. Ksharp,

 

Thank you very much! This one is close to waht I want, but the line doesn't show up, I use SAS 9.3, probably SAS version problem? Thanks again.

Grand Advisor
Posts: 9,315

Re: Double line at specific location in proc report




data lines;
input section column1$ column2$ column3$ column4$ column5$;
return;
cards;
1 A B C D E
1 A B C D E
1 A B C D E
1 B C D E F
1 B C D E F
1 C D E F G
2 C D E F G
;
run;


ods rtf file = "/folders/myfolders/example_lines.rtf" style=journal;
ods escapechar='~';
proc report data=lines NOWINDOWS 
STYLE(report)={frame=box rules=cols}
style(header)={borderbottomwidth=2pt borderbottomcolor=black};
title '3) Using border lines as a divider';
column section column1 column2 column3 column4 column5 section;
define section / order order=data noprint;
define column1 / "Column 1";
define column2 / "Column 2";
define column3 / "Column 3";
define column4 / "Column 4";
define column5 / "Column 5";
compute after section ;
line=
"~S={height=1px cellpadding=0 bordertopwidth=2pt borderbottomwidth=2pt 
bordertopstyle=solid borderbottomstyle=solid 
bordertopcolor=black borderbottomcolor=black }  " ;
len=0;
if section=1 then len=200;

line line $varying200. len;
endcomp;
run;
ods rtf close;

SAS Super FREQ
Posts: 8,642

Re: Double line at specific location in proc report

Hi:

  Another way to do it without using CALL DEFINE is to test the value of the grouping variable. The borders around the LINE output will only appear when you are displaying the LINE. With a length of 0, the border between CANADA and PACIFIC do not show because the LINE is suppressed.

 

cynthia

 

get_rid_border.png

Occasional Contributor
Posts: 9

Re: Double line at specific location in proc report

Thank you so much! Cynthia_sas,

 

This one works great!

New Contributor
Posts: 3

Re: Double line at specific location in proc report

Nice to meet you, My name Ozawa from Japan.

May I have additional question.

 

Can I have lilke a attachement table  ( below image table ) ?

 

無題.png

Ozawa

 

Grand Advisor
Posts: 9,315

Re: Double line at specific location in proc report

How about this one ?






data lines;
input section column1$ column2$ column3$ column4$ column5$;
return;
cards;
1 A B C D E
1 A B C D E
1 A B C D E
1 B C D E F
1 B C D E F
1 C D E F G
2 C D E F G
;
run;
data _null_;
 set lines;
 by section;
 if last.section and section=1 then call symputx('n',_n_);
run;
%put &n ;

ods rtf file = "/folders/myfolders/example_lines.rtf" style=journal;
proc report data=lines NOWINDOWS  out=x
STYLE(report)={frame=box rules=cols cellspacing=0 }
style(header)={borderbottomwidth=2pt borderbottomcolor=black};
title '3) Using border lines as a divider';
column section column1 column2 column3 column4 column5;
define section / order order=data noprint;
define column1 / "Column 1";
define column2 / "Column 2";
define column3 / "Column 3";
define column4 / "Column 4";
define column5 / "Column 5";

compute column5;
count+1;
if count=&n then 
call define(_row_,'style','style={borderbottomstyle=double}');
endcomp;
run;
ods rtf close;



Attachment
New Contributor
Posts: 3

Re: Double line at specific location in proc report

Thank you Ksharp.

1st  I submitted your code in SAS 9.2 (our company's environment) .

    => Did not appear the double line.

 

I show your attachment 'x.png' , I think SAS version issue.

Next, I submitted   your code in SAS OnDemand for Academics (SAS Studio).

    => Displayed the double line. Good for me.

 

 

result.png

Thank you

 

Ozawa

 

 

 

SAS Super FREQ
Posts: 8,642

Re: Double line at specific location in proc report

Hi:
SAS OnDemand for Academics is running SAS version 9.4 so you are observing differences between SAS 9.2 and SAS 9.4. If you have questions about version differences, you should work with Tech Support. Typically, something that works in a later version, such as SAS 9.4 may or may not work in an earlier version such as SAS 9.2.

cynthia
New Contributor
Posts: 3

Re: Double line at specific location in proc report

cynthia.

 

There is no problem.
Our company will soon update the SAS9.4.

 

Thank you

 

Ozawa

Post a Question
Discussion Stats
  • 15 replies
  • 684 views
  • 2 likes
  • 4 in conversation