BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello dear SAS users,
I do not understand why i do not have the same type of dataset reporting between RTF and HTML for the following exemple.
Have you an idea to correct it ?
What i want it's the dataset reporting like RTF do.

data test1;
var_c="CHARLEMAGNE";
var_n=1.52;
flag=0;
bigflag=1;
output;
var_c="CHARLEMAGNE";
var_n=1.35;
flag=1;
bigflag=1;
output;
var_c="louis XIV";
var_n=1.52;
flag=0;
bigflag=1;
output;
var_c="louis XIV";
var_n=1.35;
flag=1;
bigflag=1;
output;
run;

proc template;
define table summer ;
column var_c var_n flag bigflag;
cellstyle flag=1 as { borderbottomcolor=black borderbottomstyle=double },
flag=0 as { borderbottomcolor=black};

define var_c;header=_label_;just=c;vjust = c; id;
cellstyle bigflag=1 as {borderbottomcolor=black borderbottomstyle=double},
bigflag=0 as {borderbottomcolor=black} ;
blank_internal_dups;
translate _val_ eq . into "---" , _val_ eq "" into "---" ,compress(_val_) eq "." into "---";
end;
define var_n; header=_label_;just=c;vjust = c; end;
define flag; print=no; end;
define bigflag; print=no; end;
balance=on;
center=on;
justify=on;
classlevels;
end;
run;

ods html file="C:\html_output.html";
ods rtf file="C:\rtf_output.rtf";
data _null_ ;
set test1;
file print ods=(template='summer');
put _ods_;
run;

ods _all_ close;

Thank you for your help.
4 REPLIES 4
Andre
Obsidian | Level 7
Monpe

add style=minimal and both destinations will produce the same results

The differences are comming from the style

HTH
Andre
Cynthia_sas
SAS Super FREQ
Hi:
Perhaps style=minimal will give you the results you desire. However, I suspect that you mean something else when you say that you do not have the same kind of reporting between RTF and HTML. I suspect that you might be referring to the look and feel of the interior table lines in the output.

If I look at the data from your program, I see the presence of the FLAG and the BIGFLAG variables:
[pre]
Obs var_c var_n flag bigflag

1 CHARLEMAGNE 1.52 0 1
2 CHARLEMAGNE 1.35 1 1
3 louis XIV 1.52 0 1
4 louis XIV 1.35 1 1

[/pre]

and, then in your TABLE template, you have 2 CELLSTYLE...AS statements that seem to be trying to alter the border bottom based on the values of either FLAG or BIGFLAG values:
[pre]
proc template;
define table summer ;
column var_c var_n flag bigflag;
cellstyle flag=1 as { borderbottomcolor=black borderbottomstyle=double },
flag=0 as { borderbottomcolor=black};

define var_c;
header=_label_;
just=c;
vjust = c;
id;
cellstyle bigflag=1 as {borderbottomcolor=black borderbottomstyle=double},
bigflag=0 as {borderbottomcolor=black} ;
blank_internal_dups;
translate _val_ eq . into "---" ,
_val_ eq "" into "---",
compress(_val_) eq "." into "---";
end;
[/pre]

Also not sure what your TRANSLATE is doing since your data does not have any missing values for var_c -- but that's another issue.

I generally find that interior table lines are the hardest style attribute to change amongst the various destinations, because each destination interprets table borders and cell borders a bit differently than the other destinations.So, for example, if I do this -- without the influence of a TABLE template and only change border color and border width, compare how the different destinations use the different border colors. I would expect this same type of variation with different destinations and border styles (such as double or single).

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

proc report data=sashelp.class(obs=2) nowd
style(report)={borderbottomcolor=cyan borderbottomwidth=5
bordertopcolor=yellow bordertopwidth=5
borderleftcolor=magenta borderleftwidth=5
borderrightcolor=black borderrightwidth=5};

title "1) REPORT: borderbottomcolor= and borderbottomwidth";
column name age height;
define name / style(column)={borderbottomcolor=red borderbottomwidth=5
bordertopcolor=green bordertopwidth=5
borderleftcolor=blue borderleftwidth=5
borderrightcolor=pink borderrightwidth=5};
run;

ods _all_ close;
[/pre]
deleted_user
Not applicable
Hello,
Thank you for yours answers but
1) if i add style=minimal, it changes nothing to my problem
2) cynthia, you're right for the ..translate ..into.. but that changes also nothingto my problem
I cannot use proc report because i don't know exactly what the columns are and their number.
What i want in output for my dataset is
a) for the two first lines, "charlemagne" in the midle of the two lines and corresponding to these two lines, the two values of var_n (1.52 and 1.35)
b) for the line 3 and 4, the same but with "louis XIV" for the column var_c in the midle of the line 3 and 4
i just want no separation for the column var_c between line 1 and 2 and between lines 3and 4.

In RTF, eveything goes right ( i have what i want) but that not the way for HTML output !!
Why ?
Thank you
Cynthia_sas
SAS Super FREQ
Hi:
Some comments. I don't know why RTF and HTML are different. I suspect it has something to do with Microsoft's interpretation and rendering of the various border style attributes. With Microsoft Word, Microsoft can render as they want. With Internet Explorer, Microsoft must still stick with the W3C specs for rendering tables in a browser. If you want to know the WHY, you'll have to work with Tech Support. HTML and RTF are just different destinations and inherently contain some differences -- some more immediate and obvious (HTML output can be as wide as it needs to be; while RTF is controlled by the physical margin size and orientation) and some more subtle and not obvious until you try the same thing in both destinations (as my bordercolor program illustrated).

If you run the program I posted with the colorful borders, you will see a difference in the way that RTF and HTML both rendered the colors on each "side" of the NAME cell. If you take that experiment a step further and get rid of borderwidth on NAME, but change the border style, again, you will see different results:
[pre]
ods html file='border.html' style=sasweb;
ods pdf file='border.pdf';
ods rtf file='border.rtf';

proc report data=sashelp.class(obs=2) nowd
style(report)={borderbottomcolor=cyan borderbottomwidth=5
bordertopcolor=yellow bordertopwidth=5
borderleftcolor=magenta borderleftwidth=5
borderrightcolor=black borderrightwidth=5};

title "1) REPORT: borderbottomcolor= and borderbottomstyle";
column name age height;
define name / style(column)={borderbottomcolor=black borderbottomstyle=double
bordertopcolor=green bordertopwidth=5
borderleftcolor=blue borderleftwidth=5
borderrightcolor=pink borderrightwidth=5};
run;

ods _all_ close;
[/pre]

I am only pointing out that the rendering is DIFFERENT between HTML and RTF. I do not believe it is possible to make a single TABLE template or a single STYLE template with style attribute changes that will render the same in both destinations. In fact, I don't know whether it is even possible for HTML to render the same way as the RTF file. Again, that is a question for Tech Support.

Another comment. You said that: I cannot use proc report because i don't know exactly what the columns are and their number.

Your table template does not use GENERIC -- so right now, your TABLE template can ONLY process the variables listed, var_c and var_n, flag and bigflag. Without GENERIC you do not have a "reusable" column. And, if you do use GENERIC, then you will need a DATA step program in order to send your columns to the TABLE template. And, if you ARE using a DATA step program in order to set the values for FLAG and BIGFLAG, then you do have an opportunity to know EXACTLY how many columns you have, what the columns are.

With PROC REPORT, the new SPANROWS option would make the cell for Charlemagne span the 2 rows for var_n -- without an interior divider line. Then the style attribute vjust=m would center the name on the line as shown in the example below:
[pre]
ods listing close;
ods html file="C:\temp\html_output_j.html" style=journal;
ods rtf file="C:\temp\rtf_output_j.rtf" style=journal;

proc report data=test1 spanrows nowd;
title 'Show SPANROWS with JOURNAL style';
column var_c var_n ;
define var_c / order style(column)={vjust=m};
define var_n / sum;
run;
ods _all_ close;
[/pre]

cynthia

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 1203 views
  • 0 likes
  • 3 in conversation