- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying to generate table with Span Headers across different column variables. I am to add the labels and get the line beneath the span label but it looks like the underline seems to be connected to the next group. Is there a way to restrict the underline and clearly show that spanlabel "Asia" appears over column Lexus and Toyota and "Europe" appears over column Audi and BMW. Currently both underlines seems are connected.
Below is the code I am using.
data cars;
set sashelp.cars;
where origin in ("Asia","Europe");
if make in ("Audi", "BMW","Lexus","Toyota");
if drivetrain="All";
run;
proc sort data=cars out=x nodupkey;
by make origin;
run;
proc sort data=cars;
by type model drivetrain;
run;
proc transpose data=cars out=cars2;
by type model drivetrain;
id make;
var enginesize;
run;
data cars2;
set cars2;
x=1;
run;
options leftmargin=0.75in rightmargin=0.75in topmargin=0.75in bottommargin=0.75in;
ods escapechar="^";
proc template;
define style style_rtf;
parent=styles.rtf;
style SystemTitle /
font_face="Times New Roman"
font_size=8pt
font_weight=light
font_style=roman
foreground=black
background=white
;
style SystemFooter /
font_face="Times New Roman"
font_size=8pt
font_weight=light
font_style=roman
foreground=black
background=white
;
style Header /
font_face="Times New Roman"
font_size=8pt
font_weight=light
font_style=roman
foreground=black
background=white
;
style Data /
font_face="Times New Roman"
font_size=8pt
font_weight=light
font_style=roman
foreground=black
background=white
;
style Table /
foreground=black
background=white
cellspacing=0
cellpadding=3
frame=hsides
rules=groups
;
style Body /
foreground=black
background=white
;
style SysTitleAndFooterContainer /
cellspacing=0
;
end;
run;
ods rtf file="spanheader.rtf" style=style_rtf;
title1 'Western Region Summary';
proc report data=cars2 nowd style(report)={cellwidth=100%};
column type model drivetrain ("Asia" ('^S={borderbottomwidth=1 borderbottomcolor=black}' Lexus Toyota)) ("Europe" ('^S={borderbottomwidth=1 borderbottomcolor=black}' Audi BMW)) x;
define Type / style(column)={width=40mm} group;
define drivetrain / "Drive Train" group style(column)={width=30mm};
define model / "Model" group style(column)={width=30mm} ;
define Lexus / display style(column)={width=10mm} ;
define Toyota / display style(column)={width=10mm} ;
define Audi / display style(column)={width=10mm} ;
define bmw / display style(column)={width=10mm} ;
define x/ noprint;
run;
ods rtf close;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
I assume that you want to see this
with a slight break between the header for Asia and the one for Europe.
In this example, I did NOT use your template. Instead I just used the simple journal style and made some slight modifications to your REPORT code. First, to avoid warning messages and notes in the log, I changed all of your GROUP usage items to ORDER usage. Next, I did not see the purpose for the X variable, so I didn't use it at all.
However, to insert the slight space, I just created a helper variable called BLANKVAR that was computed. Journal style turns off all interior table lines by default, so by inserting the new helper BLANKVAR between Asia and Europe columns, it makes the report look like there's a break and there is, you just need to manually control it.
Since you have width=100%, I did not see the need to overcontrol the column widths except that DRIVETRAIN needed to be a bit wider, so I left that. And, then I had to use BLANKVAR in the COLUMN statement.
The biggest change I made was in the placement of your border overrides. If you want to alter the borders of the spanning header text strings so they are looking like an underline, then your ODS ESCAPECHAR override needs to appear BEFORE the string, not after as you originally showed. Here's the changed code:
I'm also pasting the code below, with an example of how Journal style looks using TEXTDECORATION. But I wanted to provide you with the annotated changes too.
Cynthia
** did not change data creation steps although X variable does not seem to be needed;
options missing=' ' orientation=portrait
topmargin=0.75in bottommargin=0.75in leftmargin=0.5in rightmargin=0.5in;
ods escapechar='^';
ods rtf file="c:\temp\span_journal.rtf" style=journal;
title1 'Western Region Summary (journal style use borderchanges)';
proc report data=cars2 nowd style(report)={width=100%}
style(header)={font_style=roman font_weight=bold};
column type model drivetrain ('^S={borderbottomwidth=1 borderbottomcolor=black}Asia' (Lexus Toyota))
blankvar
('^S={borderbottomwidth=1 borderbottomcolor=black}Europe' (Audi BMW)) ;
define Type / order;
define drivetrain / "Drive Train" order style(column)={width=30mm};
define model / "Model" order ;
define Lexus / display ;
define Toyota / display ;
define blankvar / computed ' ';
define Audi / display ;
define bmw / display ;
compute blankvar/character length=15;
blankvar = '^{nbspace 3} ';
endcomp;
run;
title1 'Western Region Summary (journal style show textdecoration)';
proc report data=cars2 nowd style(report)={width=100%}
style(header)={textdecoration=underline font_style=roman font_weight=bold};
column type model drivetrain ("Asia" (Lexus Toyota)) ("Europe" (Audi BMW)) ;
define Type / order;
define drivetrain / "Drive Train" order style(column)={width=30mm};
define model / "Model" order ;
define Lexus / display ;
define Toyota / display ;
define Audi / display ;
define bmw / display ;
run;
ods rtf close;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Can you provide an example of what you want to create?
I actually don't see anything UNDERLINING in your code. You are using style options that affect cell borders appearnace and cell borders are the width of a cell. So adjacent "cells" will appear connected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
I assume that you want to see this
with a slight break between the header for Asia and the one for Europe.
In this example, I did NOT use your template. Instead I just used the simple journal style and made some slight modifications to your REPORT code. First, to avoid warning messages and notes in the log, I changed all of your GROUP usage items to ORDER usage. Next, I did not see the purpose for the X variable, so I didn't use it at all.
However, to insert the slight space, I just created a helper variable called BLANKVAR that was computed. Journal style turns off all interior table lines by default, so by inserting the new helper BLANKVAR between Asia and Europe columns, it makes the report look like there's a break and there is, you just need to manually control it.
Since you have width=100%, I did not see the need to overcontrol the column widths except that DRIVETRAIN needed to be a bit wider, so I left that. And, then I had to use BLANKVAR in the COLUMN statement.
The biggest change I made was in the placement of your border overrides. If you want to alter the borders of the spanning header text strings so they are looking like an underline, then your ODS ESCAPECHAR override needs to appear BEFORE the string, not after as you originally showed. Here's the changed code:
I'm also pasting the code below, with an example of how Journal style looks using TEXTDECORATION. But I wanted to provide you with the annotated changes too.
Cynthia
** did not change data creation steps although X variable does not seem to be needed;
options missing=' ' orientation=portrait
topmargin=0.75in bottommargin=0.75in leftmargin=0.5in rightmargin=0.5in;
ods escapechar='^';
ods rtf file="c:\temp\span_journal.rtf" style=journal;
title1 'Western Region Summary (journal style use borderchanges)';
proc report data=cars2 nowd style(report)={width=100%}
style(header)={font_style=roman font_weight=bold};
column type model drivetrain ('^S={borderbottomwidth=1 borderbottomcolor=black}Asia' (Lexus Toyota))
blankvar
('^S={borderbottomwidth=1 borderbottomcolor=black}Europe' (Audi BMW)) ;
define Type / order;
define drivetrain / "Drive Train" order style(column)={width=30mm};
define model / "Model" order ;
define Lexus / display ;
define Toyota / display ;
define blankvar / computed ' ';
define Audi / display ;
define bmw / display ;
compute blankvar/character length=15;
blankvar = '^{nbspace 3} ';
endcomp;
run;
title1 'Western Region Summary (journal style show textdecoration)';
proc report data=cars2 nowd style(report)={width=100%}
style(header)={textdecoration=underline font_style=roman font_weight=bold};
column type model drivetrain ("Asia" (Lexus Toyota)) ("Europe" (Audi BMW)) ;
define Type / order;
define drivetrain / "Drive Train" order style(column)={width=30mm};
define model / "Model" order ;
define Lexus / display ;
define Toyota / display ;
define Audi / display ;
define bmw / display ;
run;
ods rtf close;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Cynthia,
Thanks for taking time and providing a working solution.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You could try RTF code ^R'\brdrb\brdrs\brdrw15
data cars;
set sashelp.cars;
where origin in ("Asia","Europe");
if make in ("Audi", "BMW","Lexus","Toyota");
if drivetrain="All";
run;
proc sort data=cars out=x nodupkey;
by make origin;
run;
proc sort data=cars;
by type model drivetrain;
run;
proc transpose data=cars out=cars2;
by type model drivetrain;
id make;
var enginesize;
run;
data cars2;
set cars2;
x=1;
run;
options missing=' ' orientation=portrait
topmargin=0.75in bottommargin=0.75in leftmargin=0.5in rightmargin=0.5in;
ods escapechar='^';
ods rtf file="c:\temp\span_journal.rtf" style=journal;
title1 'Western Region Summary (journal style use borderchanges)';
proc report data=cars2 nowd style(report)={width=100%}
style(header)={font_style=roman font_weight=bold};
column type model drivetrain ("^R'\brdrb\brdrs\brdrw15 'Asia" (Lexus Toyota))
("^R'\brdrb\brdrs\brdrw15 'Europe" (Audi BMW)) ;
run;
ods rtf close;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ksharp,
The solution mentioned works as expected for RTF but for PDF do we have something similar control words we can use?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
or you could try to SAVE AS this rtf file into a PDF file in the WORD menu.