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

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!

 


fig1.jpg
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

View solution in original post

15 REPLIES 15
Cynthia_sas
SAS Super FREQ
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
Jerrynetwork
Obsidian | Level 7

Ksharp
Super User


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;
Jerrynetwork
Obsidian | Level 7

Thank you! Ksharp,

 

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

Ksharp
Super User
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;

Jerrynetwork
Obsidian | Level 7

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.

Ksharp
Super User



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;

Cynthia_sas
SAS Super FREQ

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

Jerrynetwork
Obsidian | Level 7

Thank you so much! Cynthia_sas,

 

This one works great!

Ozawa
Calcite | Level 5

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

 

Ksharp
Super User
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;




x.png
Ozawa
Calcite | Level 5

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

 

 

 

Cynthia_sas
SAS Super FREQ
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
Ozawa
Calcite | Level 5

cynthia.

 

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

 

Thank you

 

Ozawa

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 15 replies
  • 6390 views
  • 2 likes
  • 4 in conversation