The SAS Output Delivery System and reporting techniques

ODS template questions

Posts: 43

ODS template questions

I am digging ODS techniques and have some questions:

What is the difference between ODS MARKUP and ODS TAGSETS?
I think they are the same. Right?


Style template is not required to ODS TAGSET output. For example, CSV output do not need style presentation. Right?

How is the style applied to ODS TAGSET output?

It is easy to understand non-tagset output since we can know destination in advance.

For example, as to same style definition (e.g. bold, red color, etc), TAGSETS.RTF and TAGSETS.EXCELXP must use different control code. How do the style identify this difference?

Any comment will be appreciated.
Super Contributor
Posts: 394

Re: ODS template questions

#1. Essentially yes. The ODS MARKUP statement and the ODS Tagset statement are two different ways to specify the type of markup you want.

#2. No. ODS TAGSETS.RTF is "measured." ODS RTF is not. See for more information.

#3. The tagset is independent of the style template. If you don't specify a style then the tagset will use the default style if necessary. CSV won't find it necessary, but HTML will.

#4. The style doesn't need to know about the destination. Only the tagset needs to know. The style supplies values to style variables to which the tagset may refer. For example, the BACKGROUND variable has the background color specified by the style.

Hope this helps!
Posts: 9,373

Re: ODS template questions

To add .02 on #4. How you actually specify a style is with the STYLE= option. For example to build on Tim's comment:
ODS HTML file='will_use_style.html' style=sasweb;
ODS CSV file='will_NOT_use_style.csv' style=sasweb;

Both of those may appear to work, however, the HTML tagset template was coded to -know- and -use- style elements to build the output file. But the CSV tagset template was coded to -not use- style elements to build the output file. So, just because I specified a style on the ODS CSV invocation, the style specification is irrelevant and unnecessary because ODS CSV or more accurately, the tagset template that is used to create the ODS CSV output file does not use the style template.

You are correct, in your last statement that TAGSETS.EXCELXP and TAGSETS.RTF or HTML all will use different "control codes" or markup tags to specify "bold" versus "red" and how to start a table and how to start a table row. Let's take the SAS title statement for example. You code this:
ods listing close;
ods html file='whattitle.html' style=sasweb;
ods tagsets.rtf file='whattitle.rtf' style=sasweb;

title bold c=red "Wombat";
proc print data=sashelp.class(obs=2);
ods _all_ close;

in the HTML file, you will see this markup:
<td class="c SystemTitle" style=" font-weight: bold; color: #FF0000;">Wombat</td>

versus this in the RTF file (if you look at it with Notepad):

So that single TITLE statement from the SAS program got handled as appropriate for each destination. To look at the underlying markup tags or control string information, I opened each output file in Notepad.

You get the different markup because the person who coded the tagset template coded the SystemTitle event to write different markup control strings or tags for each destination. It was probably someone how knew HTML really, really well, who coded the HTML tagset and someone who knew RTF really, really well who coded the RTF tagset. What they needed to know was that the SAS title would be contained in the event variable information for the SystemTitle event. In other words, the information that SAS "sends" to the tagset template controlled destination (or Markup destination) does not change. How each destination HANDLES the event information is what will change.

For a longer discussion of EVENTS and EVENT handling in Tagset Templates, consult the documentation or previous papers on ODS MARKUP and TAGSET Templates.

(OK, I guess that was more .05 than .02 worth of adding on...sorry if that's too much information.)
Posts: 43

Re: ODS template questions

Posted in reply to Cynthia_sas
Tim and Cynthia, thank you for the reply.

As to the sample code in Cynthia's reply, I have a follow up question.

I think there should be a map table for the style, for example,
"color=red" will be translated into "color: #FF0000;" in html or "\cf6" in rtf.

In the tagsets.rtf, I can position the code at below:

define event data;
/* other statements */
put "\cf" FOREGROUND;
/* other statements */

I have searched FOREGROUND but find nothing in source code of tagsets and styles.
I think it should be a style variable.
My question is where is it defined? Message was edited by: Kevin Qin
Super Contributor
Posts: 394

Re: ODS template questions

It's the responsibility of the tagset to convert the style attribute values such as "red" to their equivalent markup representation. That is, the RTF tagset must be able to convert "red" to "\cf6", or whatever is appropriate. HTML is fortunate since color="red" is already a perfectly acceptable attribute.

I see FOREGROUND being used in the cascading_stylesheet tagset, which is an ancestor of the HTML4 tagset. It's lowercased, though, so search for "foreground".

You can find out what style variables are available for each event by running a test program with one of the mapping tagsets such as short_map or event_map. Here's a good paper that describes the process:
Posts: 43

Re: ODS template questions

Thank you for the reply. It is helpful.

Ask a Question
Discussion stats
  • 5 replies
  • 3 in conversation