• Print  |
  • Feedback  |

FOCUS AREAS

Return to SAS 9

Base SAS

Enhancements to Inline Formatting in SAS 9.2


Introduction

This topic demonstrates some of the new features for inline formatting in SAS 9.2. See also some RTF examples that use inline formatting.


Nesting Inline Styles

In addition to a new syntax, inline styles can now be nested. The general format for the new inline style syntax is:

  ^{function-name <arg-1 <arg-2 ... <arg-n>>>}

where "^" is the ODS escape character, "{" and "}" are the inline style grouping characters, function-name is the name of the inline function, and arg-1 ... arg-n are the arguments to the given function. The number of arguments depends on the function.

Here are some examples of some inline formatting functions:

  ^{dagger}
  ^{super 2}
  ^{unicode 3609}
  ^{style [color=green] formatted text}

Note that DAGGER has no argument; it simply displays a dagger character. SUPER and UNICODE have one argument. STYLE is the most complex. It essentially has two arguments: the style override and the text to be formatted (the text can contain other inline formatting).

Here is an example of nested inline styles:

  ods escapechar="^";

  ods pdf file="nested.pdf" notoc;
  ods html file="nested.html";

  title "You ^{style [color=red] can ^{style [fontsize=18pt] do ^{super super}
        ^{style [color=blue] nested ^{sub sub} inline} styles} in} ODS";

  proc print data=sashelp.class(obs=1); run;

  ods pdf close;
  ods html close;


Unicode Characters

You can now use the UNICODE inline formatting function to select any available unicode character in the current unicode font. Simply supply it with the HEX value of the character that you want.

Note that fonts do not have every character, so you'll have to use the MS Windows Character Map accessory or a similar application to see what characters your font supports.

Here is some example code:

  /* Change unicode font to something with more characters in it */
  /* Copy this to 'unicode.sasxreg' */
  /*
  [ODS\DESTINATIONS\PRINTER]
  "Unicode Font"="Arial Unicode MS"
  */
  proc registry import = 'unicode.sasxreg'; run;

  ods escapechar='^';

  /* Create a table of unicode characters */
  data work.unicode;
  input @1 name $25. @27 value $4.;
  datalines;
  Snowman                   2603
  Black Knight              265E
  White Rook                2656
  Snowflake                 2744
  Two Fifths                2156
  Greater Than or Equal To  2267
  ;

  /* Create table that shows the name, unicode value, and actual symbol */
  proc template;
     define table unitable;
     define column name;
        header = 'Name';
     end;
     define column value;
        style={textalign=center};
        header = 'Value';
     end;
     define column symbol;
        style={textalign=center};
        header = 'Symbol';
        compute as '^{unicode ' || value || '}';
     end;
     end;
  run;

  /* Make the fonts big */
  proc template;
     define style styles.bigprinter; parent=styles.printer;
        class systemtitle, data, header /
             fontsize = 40pt;
     end;
  run;

  /* Generate report */
  ods pdf file="unicode.pdf" style=styles.bigprinter;

  data _null_;
     set work.unicode;
  file print ods=(template='unitable');
     put _ods_;
  run;

  ods pdf close;