The SAS Output Delivery System and reporting techniques

Can you apply a style template in a CALL DEFINE statement?

Reply
N/A
Posts: 0

Can you apply a style template in a CALL DEFINE statement?

I wouldn't have to worry about this if I had access to SAS 9.2, but I am trying to use some of the preproduction features to selectively change the size of the border in a cell. Failing that, how can I put RTF raw text into a call define, because it seems as if there's a quoting issue with the extra set of quotes around the RTF control string.

By the way, happy holidays everybody!
Super Contributor
Posts: 394

Re: Can you apply a style template in a CALL DEFINE statement?

Posted in reply to deleted_user
I'm not quite sure what you're wanting to do, but for starters check out the STYLE attribute for CALL DEFINE: http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473624.htm.
SAS Super FREQ
Posts: 8,868

Re: Can you apply a style template in a CALL DEFINE statement?

Posted in reply to deleted_user
Hi:
A style -TEMPLATE- is a collection of style -ELEMENTS- and the TEMPLATE includes how to apply style to report areas like the title, the footnote, the whole table, individual cells. So, it wouldn't be appropriate to apply a whole style TEMPLATE to one piece of a TABLE using CALL DEFINE.

You can change or reference style -ELEMENTS- in your CALL DEFINE statment and you can change style -ATTRIBUTES-. A very useful style ATTRIBUTE when you are using ODS RTF, is to pass your RTF control strings as PRETEXT or POSTTEXT to a cell, for example....where the TEXT you wanted to pass to ODS RTF was an RTF control string for italicizing (\i) or bolding (\b), etc.

These user group papers have some information (in addition to Tim's suggestion) that you might find helpful. They all talk about ODS RTF specifically.
http://www.lexjansen.com/phuse/2005/ts/ts01.pdf
http://www2.sas.com/proceedings/sugi28/024-28.pdf
http://www.lexjansen.com/pharmasug/2007/po/po12.pdf
http://www.lexjansen.com/phuse/2007/cs/cs08.pdf
http://www2.sas.com/proceedings/sugi29/088-29.pdf

cynthia
N/A
Posts: 0

Re: Can you apply a style template in a CALL DEFINE statement?

Posted in reply to Cynthia_sas
I have a style element in my template that uses the experimental border width settings, and I already know that I can't apply them as style attributes in CALL DEFINE under 9.1.3. I'd like to apply this style element in the CALL DEFINE to get around that probklem, because the RTF control words don't seem to work (which is an RTF issue, not a SAS issue and it's a by-product of the version of Word I'm stuck with).

Thanks again for the clarification.

Derek
SAS Super FREQ
Posts: 8,868

Re: Can you apply a style template in a CALL DEFINE statement?

Posted in reply to deleted_user
Hi:
I believe the other issue you may be running into is one of understanding which attributes are appropriate to change. Look at the table entitled "Style Attributes and their Values".
http://support.sas.com/documentation/cdl/en/odsug/61723/HTML/default/a002972093.htm (9.2 version)
http://support.sas.com/onlinedoc/913/getDoc/en/odsug.hlp/a003079951.htm (9.1.3 version)

In this doc table, you will see, for example, that "FRAME=" is only supported at the TABLE level. That means it would be inappropriate to try to set FRAME on a particular cell in a table. Similarly, the CELLPADDING attribute is a TABLE level attribute.

So, depending on what you are trying to do, it may just not be possible to alter the cells the way you want with anything other than RTF control words.

And now, the good news (I hope), in the program below, I've shown some very simple kinds of things that you can do with a STYLE template in 9.1.3 and RTF control words. Note the use of the BOXIT style element in the CALL DEFINE for the WEIGHT variable. Compare that to the way the RTF control words were used to format the HEIGHT cell for Robert. And, also note how the "\brdrt\brdrs " were put directly into the header text for the AGE, HEIGHT and WEIGHT variables

This program uses almost all the RTF control words that I know. So, for fancier control words or other formatting, you may need to look to the RTF specification for more help. But, if you supplement this with the user group papers (which were all mostly 9.1.3 papers), you should be able to achieve quite a bit.

Of course, I say that not knowing what RTF control words you've tried. One simple thing that may have held you up is that if you are using RTF control words then you MUST also use the PROTECTSPECIALCHARS=OFF style attribute -- so SAS doesn't try to do you a favor and protect any of the special RTF controls (like the \, the {} or the ~).

cynthia
[pre]
ods path work.temp(update)
sashelp.tmplmst(read);

proc template;
define style styles.my913style;
parent=styles.journal;
style Header from Header /
protectspecialchars=off;
style myothercell from cell/
pretext='\b\i'
posttext='\b0\i0'
protectspecialchars=off;
style boxit from Data/
pretext='\box\brdrs '
font_face='Arial'
font_size=9.5pt
protectspecialchars=off;

end;
run;

ods listing close;
ods rtf file='c:\temp\use_RTF_ctrl.rtf' style=my913style;

proc report data=sashelp.class nowd
style(columnn)={protectspecialchars=off};
column name ('\brdrb\brdrs {Spanning Header}' age height weight);
rbreak after / summarize
style={pretext='\brdrt\brdrs ' protectspecialchars=off};
define name / style(header)=myothercell 'Name';
define age / style(header)=header '\brdrt\brdrs {Age}';
define height / style(header)=header '\brdrt\brdrs {Height}';
define weight / style(header)=header '\brdrt\brdrs {Weight}';
compute height;
if name = 'Robert' then do;
call define(_col_,'style',
'style={pretext="\box\brdrs " }');
end;
endcomp;
compute weight;
if weight.sum gt 120 and _break_ = ' ' then do;
call define(_col_,'style','style=boxit');
end;
endcomp;

run;
ods rtf close;
[/pre]
N/A
Posts: 0

Re: Can you apply a style template in a CALL DEFINE statement?

Posted in reply to Cynthia_sas
First, thanks so much for the test program; it has definitely increased my understanding of what is going on with the RTF produced.

I can apply a border to the paragraph using PRETEXT=; that means that the characters in a cell have a border, but the cell border is a different entity. The cell borders are defined and written to the RTF file on a row-by-row basis before the row data are written, so I don't know that I can alter a specific cell border, even by applying the correct control words. The 9.1.3 pre-production "borderxxx" style attributes don't seem to work for me; I can't find any control words that might correspond in the RTF file.

Thanks again for the help.
SAS Super FREQ
Posts: 8,868

Re: Can you apply a style template in a CALL DEFINE statement?

Posted in reply to deleted_user
Hi:
I think you're right. I believe there's some TROWD stuff that goes on for table rows that I don't wholly understand. I mostly stick with paragraph formatting. The 9.2 style elements do make your life easier.

A couple of alternatives that come to mind are:
1) post processing the RTF file with a DATA step program -- once you do discover the control words that you need -- this can be somewhat dicey, as Word really wants the RTF to have very last \ and { and } to match up correctly before it will open the RTF file.
or
2) write a VB script or Word macro to open the RTF file, as created by SAS and apply the table changes you want and then resave the RTF file as a .DOC, .DOCX or as an RTF.

Those are the workarounds that my students most always use. And there's a 3rd option:
3) Create an ODS HTML3 or MSOFFICE2K HTML file -- use CSS style attributes to make the row borders the way you want. Then open the HTML file in Word. Under -some- circumstances, Word will respect CSS style properties.

cynthia
N/A
Posts: 0

Re: Can you apply a style template in a CALL DEFINE statement?

Posted in reply to deleted_user
Thanks for all your help, Cynthia. If I could figure out how to put page breaks in HTML output, then I could do the HTML. We moved to RTF because they couldn't just print it.
SAS Super FREQ
Posts: 8,868

Re: Can you apply a style template in a CALL DEFINE statement?

Posted in reply to deleted_user
Hi:
I wasn't talking about delivering an HTML file. I was talking about
1) creating an HTML file with the borders you want
2) opening that HTML file with Word -- if Word respects the borders then
3) SAVE the HTML file as a .DOC file -- Word should insert page breaks
4) then deliver the new (non-ODS) .DOC file

Only step 1 uses ODS. Steps 2 and 3 would be via a VB script that opened and saved the file. You could not deliver the HTML file...ODS HTML files use a CSS instruction "page-break-after: always" attached to the horizontal rule -- and not all browsers respect that instruction. That's why you have to resave and possibly adjust the page breaks in steps 2 and 3 with VB script or a Word macro.

The other option is to use a 3rd party "distiller" to convert the ODS HTML file to a PDF file -- anybody should be able to print that.

cynthia
Ask a Question
Discussion stats
  • 8 replies
  • 234 views
  • 0 likes
  • 3 in conversation