I'm not sure what you mean by "template Word table" -- the word "template" in SAS jargon can be used for several different things, AND the word "template" for Word generally means a .dot file. However, I assume you want to know what elements in the SAS style template control the different table components. (Warning -- long post!)
Tables themselves are pretty simple. The column headers are controlled by the HEADER style element; the data cells by the DATA style element (or sometimes by the CELL style element) and the TABLE itself (interior table lines, borders etc) is controlled by the TABLE element (or sometimes by the OUTPUT element). The background that the table is sitting on is generally controlled by the BODY element.
But then if your table has -titles- or -footnotes- or by lines then more style elements are involved. There are a couple of ways to figure out what style elements are involved in your table. Let me start with the easiest.
I know you're interested in Word, but first, make an HTML copy of your table (assumes SAS 9)
ods html file='diagnose.html';
proc whatever data=yourdata;
ods html close;
inside the ODS HTML sandwich, put your procedure of choice. Then, when you are looking at the HTML file in the browser, right click on the HTML page and select View-->Source. This should open a Notepad window where you will see the HTML source code. Use the FIND commmand to find the CLASS= attribute in the HTML tags. Zero in on some piece of output that you want to change (like a column header or something). Look for that string and then note the CLASS= attribute used for that string. Now go to the style template and look for that style element. --That's the element you want to change in your modification of the style template.-- Ignore the CLASS= attributes that are 'l', 'r', or 'c' -- those are just alignment classes for left, right or center. Focus instead on the whole word class selectors (like Header, Table, SystemTitle, etc).
If you are running SAS 8, you will not find a CLASS= attribute in your HTML unless you modify your invocation to have the stylesheet option:
ods html file='diag8.html' stylesheet;
I know it seems weird, but it doesn't matter WHAT the destination is (HTML, RTF or PDF) -- a table is a table is a table....a header is a header is a header. The only difference between HTML and RTF is that HTML reveals its inner workings with CLASS= way better than RTF (or PDF) does. So you're just using HTML to diagnose the style elements that you will change for your RTF style template.
Next method ... this one builds on the first one. The brilliant developers at SAS have created a "diagnostic tagset" that allows you to bypass opening the HTML source code and looking for the CLASS= attribute. So, to use the diagnostic tagset, you'd do this (works in SAS 8.2 or 9):
ods listing close;
You're still creating an HTML file, but now, if you have popups enabled in your browser, when you float your mouse over a piece of your table, the style element that controls that table component will "pop up" in a flyover window and even better, if you double click on a table component, then a second window will "pop up" that has ALL the style attribute settings currently in place for that particular element.
It's sort of hard to explain the popping up in plain text, but is really cool to watch. BTW, if you are using SAS 8.2, you may have to download an updated copy of the tagset code to your machine and create the template prior to running the above code.
Arghhh! you've read all the way down to here and you still haven't changed your style template yet! But NOW you know which style elements to really look at when you do start to tackle the style template and the PROC TEMPLATE syntax (which is being made easier for SAS 9.2). Also, you'll probably get into issues of style element inheritance once you get into PROC TEMPLATE and if you go to the SAS documentation and search for the string "Style Elements and Their Inheritances", you will find a useful table that talks about style elements and, if inheritance is involved, what element in the parent element. This table also lists the destinations in which a particular element is "respected" or supported.
My advice is to start slowly -- try to change one element in your style template and then move on to the next element. If you are interested in Word friendly styles...consider starting your style template explorations with Styles.RTF or Styles.Journal -- they currently produce that best Word friendly output (in my opinion).
BTW, Enterprise Guide has a very nice GUI style editor, that lets you visually select pieces of the table and alter the style. But I sense that you are not using EG because most EG folks don't ask about PROC TEMPLATE and EG is NOT changing a style template behind the scenes, but constructing a .CSS file for ODS to use.
Thanks for that detailed reply. I'll have a look through all the sources you've put down. I knew about a few of them but I wondered if you guys at SAS had more information .... and you do. Thanks again.
I thought EG might have some fancy wizzy way with changing a style sheet but are the changes recordable in code. Working in the pharma industry we can't just do on-the-fly changes for stuff we're delivering to our customers or regulatory authorities. We need to be able to repeat everything we do in a program (generally batch-submitted as well).
EG does have a cool style sheet editor. It makes a CSS file. So the new stylesheet contains ALL the style properties being used for the new style sheet. The Wizard shows you the "current" style in a GUI interface, you make changes (mostly color and font choices) inside the interface and the wizard makes a new CSS file that contains the results of making your changes. The individual changes themselves (you changed the header background color from cxB0B0B0 to cx336699) are not put into any kind of code file, but are written directly to the new CSS file. I don't think that most folks make on-the-fly CSS files for every other report.
What generally happens is that you either manually edit or create a CSS file or you use a wizard like the EG wizard and then once your CSS file is "cooked", you use that same CSS file over and over again. Since the CSS file is just an ASCII text file, there is no hidden, behind the scenes code being executed. You make a CSS file, you use the CSS file. CSS is fairly standard web technology -- nobody ever writes a CSS file from scratch, they always start with -something- and then modify it.
Starting in SAS 9.2, you will be able to import a CSS file into a SAS style template. That is really cool because it means that if you have a corporate CSS file and you want to import it into a style template format, then you'll be able to use that CSS file as the basis for a SAS style template -- for use with destinations that don't support CSS.
If you do need to repeat everything in code, then investigating style template syntax, for now, will be the way to record how you are changing the style template used for your output. Since you can create a CSS file FROM a style template (by using the STYLESHEET= syntax of ODS), this gives you a direct link between the style template and the CSS file.
This all looks interesting. I've played around with styles in EG (4.1) but what I find is that, because SAS runs on a remote server, under a different OS (Solaris), it doesn't get added to the available styles there. As a result, a warning appears in the log and the default style is used.
I expect there's something I'm missing, but not sure what.
Yes, sadly, EG generally references local copies of the SAS CSS style sheets. All that's available on the server are the templates that are installed with SAS on the server and/or any CSS files that you put on the server.
EG sometimes makes a references to a local CSS file -- which you would have to change. What would be the best situation, in my opinion, for EG users would be for the SAS Administrator to take the most commonly used EG CSS style sheets and move them onto the server where SAS lives. Or, to translate the EG CSS style sheets into SAS style templates and then the EG folks could do a simple STYLE= reference.
The good news for SAS 9.2 is that there will be a couple of new features in place that make it easier to use CSS stylesheets with SAS and EG -- the new CSSSTYLE= option will allow you to use a SAS-compatible CSS file with RTF and PDF -- without first turning the CSS syntax into SAS template syntax. I am not sure yet how the new CSSSTYLE option will be surfaced in EG. The existing STYLESHEET= option is not surfaced in EG at the moment -- you have to know what you're doing to use the option.
But this may help you in the short term...let's say you have a CSS file on the server -- you can always do this:
ODS HTML path='path on server to save file' (url=none)
ODS HTML CLOSE;
and then when the server copy of the file is retrieved, the browser will go to the URL location to find the CSS file to use with the HTML file. If the server CSS file is available when the results are viewed in EG, then you will see the CSS styles being used by the EG internal browser. However, if the server CSS file is not available to EG, then you will not see the style when you view the results in EG.
So the ultimate disposition of the result files does make a difference about how/whether to use the STYLESHEET=(URL=) technique.
Tech Support can help you figure out the correct way to build your ODS invocation, based on the configuration that you have and they can help you with the PROC TEMPLATE syntax to recreate templates on the server machine if you decide to go that route.