1 / 51

The Great Escape(char)

Abt Associates Inc. The Great Escape(char). Prepared by Louise Hadden Lead Programmer Analyst April 2010. The Great Escapechar. What will we see in this presentation?. Basic syntax of ODS ESCAPECHAR ODS ESCAPECHAR in titles and footnotes ODS ESCAPECHAR with ODS text fields

Audrey
Download Presentation

The Great Escape(char)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Abt Associates Inc. The Great Escape(char) Prepared by Louise Hadden Lead Programmer Analyst April 2010

  2. The Great Escapechar What will we see in this presentation? Basic syntax of ODS ESCAPECHAR ODS ESCAPECHAR in titles and footnotes ODS ESCAPECHAR with ODS text fields ODS ESCAPECHAR with SAS procedures New Capabilities in SAS V9.2

  3. The Great Escapechar What is ODS ESCAPECHAR? Funny squiggly stuff like ^ or ~ in your data or SAS® code!

  4. The Great Escapechar ODS ESCAPECHAR is a “code” used in a SAS® program that produces ODS output. It switches on inline formatting for specified elements of the output. The code and commands are not visible in ODS output, but the results are! As the name implies, ODS ESCAPECHAR is designed to be used in output designated for the Output Delivery System. The default SAS® listing destination is not able to translate the formatting commands.

  5. The Great Escapechar What are some of the things you can do with ODS ESCAPECHAR?

  6. The Great Escapechar • Modify text strings such as titles, footnotes, and ODS text fields. • Modify variable values through in-line style commands, proc format, and the data step. • ODS ESCAPECHAR is a good way to put the finishing touches on your SAS reports and graphics, without needing to post-edit.

  7. The Great Escapechar I’ll briefly demonstrate the use of ODS ESCAPECHAR in three different ODS destinations: RTF, PDF and HTML.

  8. The Great Escapechar

  9. The Great Escapechar Where can you use ODS ESCAPECHAR? In ODS output: in titles and footnotes, ODS text fields, SAS procedures, and the data step.

  10. The Great Escapechar How do you use ODS ESCAPECHAR?

  11. The Great Escapechar Open your ODS destination(s) Specify an ODS ESCAPECHAR Feed in data containing your ODS ESCAPECHAR OR specify in-line style commands using your ODS ESCAPECHAR Close your ODS destination(s)

  12. The Great Escapechar Specify your ODS ESCAPECHAR: ODS ESCAPECHAR=‘^’; Examples of commonly used “ESCAPECHARs” are “^”, “~”, and “#”.

  13. The Great Escapechar You want to use one that would not ordinarily be found in SAS® data or procedural commands. Mainframe users will want to be particularly careful in specifying ESCAPECHARs: for example, the “^” is problematic with some mainframe operating systems and software.

  14. The Great Escapechar The defaults, *ESC* (version 9) and ‘03’x (version 8.2), contain multiple keystrokes and are used less frequently (we programmers being a lazy [or efficient!] bunch.) It is also possible to specify longer ESCAPECHARs if you want (but why would you?)

  15. The Great Escapechar Feed in data containing your ODS ESCAPECHAR: column1 Frequency Percent ----------------------------------------------------------------- **The probability is 99% or more that your 1 25.00 *The probability is 95% or more that your 1 25.00 ^{style [fontsize=6pt] ^{dagger}^{dagger}}The 1 25.00 ^{style [fontsize=6pt] ^{dagger}}The 1 25.00 proc freq data=footer; tables column1; run;

  16. The Great Escapechar In general, the way to use ODS ESCAPECHAR in data or in commands is to specify the escapechar (in this case the ^) and then commands enclosed in curly brackets {}. These can be nested as seen above.

  17. The Great Escapechar Daggers (a special ODS ESCAPECHAR function) appear in the ODS output of PROC FREQ.

  18. Titles and Footnotes The most common usage of ODS ESCAPECHAR is in titles, footnotes and ODS text fields. These are some of the functions you can use.

  19. Titles and Footnotes Text functions: Superscripts & Subscripts title2 height=2 color=red '^{super SUPER }' color=blue 'COOL ' color=black '^{sub Title Special Functions (Super, Sub) in V9.1}';

  20. Titles and Footnotes Text functions: Special Characters title3 height=4 color=red '^{dagger} Title Special Functions (Dagger) in V9.1';

  21. Titles and Footnotes Text functions: Pre-Image (Post-Images work the same) title4 height=5 '^S={preimage="bonnietiny.jpg"}' "Title Pre-Image in V9.1";

  22. Titles and Footnotes Text functions: Line Breaks title5 height=2 'Show Line Break in V9.1 ^nHere is an Extra Line ^nHandy if you want to exceed the 10 title line limit!';

  23. Titles and Footnotes Text functions: RTF Control String title6 height=3 '^\ul Feed in Underline Command in V9.1 (RTF Only) ^\ul0'; You can also do HTML control strings in the same fashion.

  24. Titles and Footnotes

  25. Titles and Footnotes Special functions: Pageof, thispage, lastpage title1 'Page ^{thispage} of ^{lastpage} - for RTF & PDF'; title4 height=4 color=blue '^{thispage} of ^{lastpage} Title thispage-lastpage in V9.1 - RTF and PDF Only';

  26. Titles and Footnotes RTF destination PDF destination

  27. ODS Text Fields The ODS text command within ODS statements in “Printer” destinations such as RTF and PDF allows the user to insert lines of text after titles and procedures at will – or without running any procedures at all! ods rtf text='{\animtext1 This is an example of inserting a text field.}'; Full Disclosure: \animtext1-6 only works with RTF. But it is very cool! “Real” examples of using ODS text fields are coming up.

  28. ODS Text Fields ods pdf text = '^S={font_size=18pt just=c font_face=Klingon} This is Klingon'; ods pdf text = '^S={font_size=18pt foreground=blue just=c font_face=Romulan} This is Romulan'; ods pdf text = '^S={font_size=18pt font_weight=bold foreground=brown just=c font_face=Federation} This is Federation'; ods pdf text = '^S={font_size=18pt foreground=green just=c font_face=trek} This is NOT Klingon or Romulan or Federation'; ods pdf text = '^S={font_size=18pt foreground=purple font_style=italic just=c font_face=arial} This is boring Arial';

  29. ODS Text Fields How cool is that?

  30. Procedural Output columns fmtvar ('Main Partner^{super **}' ( ('Sex' count1 colper1) ('Unprotected Sex^{super****}' count2 colper2) ) ) ('Non-Main Partner^{super***}' ( ('Sex' count3 colper3) ('Unprotected Sex^{super****}' count4 colper4) ) ) count boldit; Superscript - RTF

  31. Procedural Output columns fmtvar ('^S={background=lightblue}Aged 18 to 24' count_msm1 colper_msm1) ('Aged 25 to 34' count_dm1 colper_dm1) . . . Background Color of Spanning Headers - RTF

  32. Procedural Output The code on the next page demonstrates using ODS ESCAPECHAR and some special functions (dagger and sigma) in procedural output. Both data step and PROC FORMAT functionality are used. NOTE: as in the special page numbering functions described above, HTML output should have an HTML extension, and RTF output should have an RTF extension, for these special functions to work reliably.

  33. Procedural Output Procedure: ods pdf file='dagger_v91.pdf' style=styles.journal; ods rtf file='dagger_v91.rtf' path=odsout style=styles.journal; ods html file='dagger_v91.html' path=odsout style=styles.journal; ods escapechar='^'; proc print data=printit noobs; var oneunfmted one dagger doubledagger sigma; format one one.; title1 color=red bcolor=black 'Test Special Functions - V9.1'; run; ods _all_ close; Even though you are not specifying any commands with ODS ESCAPECHAR within the procedure, you MUST have the ods escapechar= command in order to print the embedded commands.

  34. Procedural Output HTML

  35. Procedural Output

  36. Procedural Output

  37. Procedural Output proc format; value xit 1="Green" 2="Red"; value xtoo 1="1 ^n Yes" /* ODS ESCAPECHAR N */ 2="2 ^n No"; value $ fit "1"-<"2"="Green" "2"-<"3"="Red"; run; data one; length feed $ 132; xit=1; xtoo=2; feed=cat("1 ","^R/HTML'<BR/>' ^R/RTF'\line'"," Yes"); /* ODS ESCAPECHAR R */ run; data two; length feed $ 132; xit=2; xtoo=1; feed=cat("2 ","^R/HTML'<BR/>' ^R/RTF'\line'"," No"); /* ODS ESCAPECHAR R */ run;

  38. Procedural Output /* Note that the string defining the variable FEED includes a line feed for both PDF and RTF and a tab for HTML */ data printit; set one two; run; ods pdf file='style_format_v91.pdf' style=styles.journal; ods rtf file='style_format_v91.rtf' path=odsout style=styles.journal bodytitle; ods html file='style_format_v91.html' path=odsout style=styles.journal; ods escapechar='^'; proc print data=printit label noobs; var xit / style={just=l foreground=xit.}; var xtoo; var feed / style={just=l foreground=$fit.}; format xtoo xtoo. ; title1 ‘Line Feeds’; run; ods _all_ close;

  39. Procedural Output HTML RTF PDF As can be seen, the variable FEED is shown both color-coded and with a line feed in the PDF and RTF destinations, and both color-coded and with a tab in the HTML destinations. The control strings embedded in the FEED variable do not print.

  40. ODS ESCAPECHAR looks great! So, why wouldn’t you use ODS ESCAPECHAR? • In-line style commands take up a lot of room (both in terms of variable length if using a data step or PROC FORMAT and in terms of ODS file size.) • And . . . Not all features are available for all ODS destinations. • Where file size is a concern, PROC TEMPLATE is a better bet as the style commands only occur once in a style template but many times when specifying in-line styles. All in all though, ODS ESCAPECHAR is great!

  41. Now Available in SAS Version 9.2! Some added functionality of ODS ESCAPECHAR in V9.2 includes unicode characters and special text decoration (underline, strike-through, lineover, etc.) There is also a greater capability for nesting style commands.

  42. New Attractions in SAS® V9.2UNICODE CHARACTERS

  43. New Attractions in SAS® V9.2UNICODE CHARACTERS smiley='^{style [fontsize=14pt] ^{unicode 263B} black smiley}'; label smiley='^{unicode 263b} Smile,^n Smile,^n Smile!‘; PDF destination

  44. New Attractions in SAS® V9.2UNICODE CHARACTERS RTF destination HTML destination

  45. New Attractions in SAS® V9.2TEXT DECORATION STYLE ATTRIBUTE RTF

  46. New Attractions in SAS® V9.2TEXT DECORATION STYLE ATTRIBUTE PDF

  47. Coming Attractions in SAS® V9.2TEXT DECORATION STYLE ATTRIBUTE HTML

  48. The End is Near

  49. Acknowledgements SUPPORT.SAS.COM – the samples, FAQs and human beings behind the scene are the greatest! Scott Huntley for his inspirational talk at SUGI 31 on the future of reporting in 9.2, and his patient, helpful advice on the use of ODS PDF. Eric Gebhart, Vince DelGobbo and Chevell Parker for introducing me to in-line styles (or style overrides as Vince prefers) in HTML-based tagsets. Sandy McNeill, Lauren Haworth and Ray Pass for introducing me to the use of in-line styles in PROC TABULATE and PROC REPORT. Cynthia Zender for her wise counsel on the use of in-line style commands and ODS ESCAPECHAR. Wayne Hester for his generous help with my problems with the RTF destination, and for coming up with really cool additions to the RTF toolset. I couldn’t have done it without them! Please read their papers listed in “Recommended Reading” below, and/or attend any of their presentations.

  50. Contact Information Your comments and questions are valued and encouraged. Contact the author at: Louise Hadden Abt Associates Inc. 55 Wheeler St. Cambridge, MA 02138 (617) 349-2385 (work) (617) 349-2675 (fax) Email: louise_hadden@abtassoc.com Sample code is available from the author upon request.

More Related