ODS Markup and Tagsets, A tutorial. Eric Gebhart
 
ODS  MARKUP!
ODS Markup & Tagsets
 
Proc Template. It is NOT what you think it is!
Tagsets are ODS Destinations ODS Markup tagset=HTML4 .... ODS Tagsets.HTML4 .... ODS HTML4 .... ODS HTML ....
ODS HTML  is   ODS Markup!
ods tagsets.short_map    file =  "body.xml"    frame =  "frame.xml"   contents =  "contents.xml&q...
Special, Named Destinations. <ul><li>HTML, PHTML, HTMLCSS, HTML4, CHTML </li></ul><ul><li>CSV, CSVByline, CSVAll </li></ul...
What is Different ? One more output file. Stylesheet Behavior. More Options.
The same options as before. Ods html file='test.html'  ( headtext ='<meta text=”my headtext”>', metatext ='text=”my meta t...
Multiple Stylesheet URL's! ODS html  file = ”test.html” stylesheet = ”test.css”  (url=” test.css corp.css corpnav.css ”);
Multiple Personality Disorder. Ods tagsets.myhtml file=”test.html” Alias=”NoNotes”;
Make up your own Options! ODS tagsets.test file=”test.txt” options ( embedded_titles  = 'yes' Orientation  = 'landscape' D...
Options inside the tagset. define tagset tagsets.test;  define event initialize; putvars $options _name_ ': ' _value_ nl; ...
The tagset Output. EMBEDDED_TITLES: yes ORIENTATION: landscape DOC: Help
One more method of control! ODS tagsets.htmlpanel file = ”test.html”; ODS tagsets.htmlpanel event = panel(start); ... ... ...
ODS Markup is like ODS HTML, PLUS!
Getting a list Proc template; list tagsets; Listing of: SASHELP.TMPLMST Path Filter is: Tagsets Sort by: PATH/ASCENDING Ob...
The HTML Family <ul><li>Phtml </li></ul><ul><li>HtmlCss </li></ul><ul><li>Html4 </li></ul><ul><li>Chtml </li></ul><ul><li>...
PHTML, Plain HTML. Simple 12 element Stylesheet No class attributes. No Fancy features.
HTMLCSS. Full Stylesheet Fancy Features
HTML4  is   ODS HTML Same as HtmlCSS More like Previous Releases
CHTML  - Compact HTML. iSNo Subset of HTML. No Styles. Super Set of Imode.
Data Transport  and  Excel. CSV, CSVByline, CSVAll PYX MSOffice2K ExcelXP DDE http://support.sas.com/news/feature/04jul/ex...
CSV &quot;Obs&quot;,&quot;Name&quot;,&quot;Sex&quot;,&quot;Age&quot;,&quot;Height&quot;,&quot;Weight&quot; &quot;1&quot;,&...
PYX (data -Alfred Atype &quot;string&quot; Ajust &quot;l&quot; Acolcount &quot;1&quot; Acol &quot;2&quot; Asection &quot;b...
The ExcelXP Tagset!
Publications, Papers,  PDF. LaTeX Troff DocBook
LaTeX Tagsets LaTeX SimpleLaTeX TablesOnlyLaTeX
Combined Slide Bars  - PDF via LaTeX
Other Miscellaneous Tagsets. ODSStyle Style_Popup Style_Display NamedHTML MVSHTML
 
Tagsets are Collections of Events
Events Define Actions & Output. define event doc; start: put HTMLDOCTYPE nl; put “<html>” nl; finish: put &quot;</html>&qu...
A very simple tagset. proc template; define tagset  tagsets.plain ;  define event  data ; put  “Data: “   value  nl; end; ...
Header: Obs Header: Name Header: Sex Header: Age Header: Height Header: Weight Header: 1 Data: Alfred Data: M Data: 14 Dat...
Label, Value Pairs Becomes this: <Table background=&quot;grey&quot; foreground=&quot;blue&quot; cellpadding=&quot;5&quot;>...
If Statements . Put 'Foreground is blue!' nl  /if  cmp ('blue', foreground); Put 'Foreground is not red!' nl  /if ^ cmp ('...
AND and OR,  sort of... Put 'Some variables have a value.' nl /if  any (background,  foreground, cellpadding,  value); Put...
Contains a Substring . Set $myvar “this is random text”; put “myvar has ran” nl  /if  contains ($myvar, “ran”);
Simple if test, Where clauses . Set $myvar “this is random text”; Set $mytest “True”; put “myvar has length” nl  /if $myva...
Break, Breakif Break  /if ^$options; Trigger alternate_event /if $do_something_else; Break  /if $do_something_else; Trigge...
A list of images. proc template; define tagset  tagsets.gifs ; define event  branch ; put  label  &quot;  &quot;;  end; de...
The Output Name=Alfred  temp/gplot.gif Name=Alice  temp/gplot1.gif Name=Barbara  temp/gplot2.gif
A Prettier Report. proc template; define tagset  tagsets.gifs2 ; define event  branch ; set  $name  scan( label , 2, '=');...
Nicer looking Output temp/gplot.gif  Alfred temp/gplot1.gif  Alice temp/gplot2.gif  Barbara
The Set Statement. set  $myvar “foreground is” forground ; Always creates a string. Variables always start with $.
The Eval Statement. Eval $count 0; Eval $count $count + 1; set $myvar “this is a test”; Eval $index index($myvar, 'test');
Data Step Functions. Can be used anywhere. Cannot be nested except in where clauses.
Simple Needs, Simple Tagsets.
SQL ??? Create table CLASS (Name varchar(7), Sex varchar(1), Age float, Height float, Weight float); Insert into CLASS(Nam...
Dictionaries define event type_translations; set $types['string'] 'varchar'; set $types['double'] 'float'; set $types['int...
The Initialize Event define event initialize; trigger type_translations; trigger name_translations; /* types that need wid...
Creating Lists define event colspec_entry; set $lowname lowcase(name); do /if $name_trans[$lowname];  set $names[] $name_t...
define event table_body; put &quot;Create table &quot; $table_name &quot;(&quot;; eval $i 1; unset $not_first; do   /while...
Looping through A Dictionary iterate  $types do   /while   _name_ ;   put  _name_  “: “  _value_  nl; next  $types; done;
XBRL,  Data Interchange
Better Stripes.
Counting Rows
Streams . <ul><ul><li>Designated by $$ </li></ul></ul><ul><ul><li>Can hold large amounts of data </li></ul></ul><ul><ul><l...
Streams by example open junk; put “This goes to junk.” nl; put “  More stuff.” nl; close; open trash; put $$junk 'This goe...
Byline Modification
Repeating Row Headers
Simple Needs, Simple Tagsets.
Slide Bars.
Craeting Slide Bars. proc print data=sashelp.class; var name; var sex; var age;  var height / style(data) =  slider[just=c...
WebSite Integration
Sashelp.class, My Favorite.
 
 
 
Tagset Inheritance . Define tagset  tagsets.SSV ; parent =  tagsets.csv ; define event  header ; start: put ';' / if ^cmp(...
Tagset Attributes Define tagset tagsets.mytags; map = '<>&'; mapsub = '/&lt;/&gt;/&amp;/'; nobreakspace = '&nbsp;' ; embed...
Using Options define event  options_set ; trigger setup_options; end; define event setup_options; trigger nls_numbers; tri...
Mvar embedded_titles; define event  options_setup ; set $options['test'] &quot;test&quot; /if ^$options; do /if  $options ...
Creating Help and documentation. define event  documentation; break /if ^$options; trigger  quick_reference  /if cmp($opti...
Extended Procedural Controls. Eval $count 10; do /while  $count < 10; eval $count $count+1; stop  /if $count = 9; continue...
Else If do /if $count < 10; put “count is < 10”; nl; else /if $count = 11; put “Count is11” nl; else /if $count = 12; put ...
A process for Tagset Creation <ul><li>Define the goal </li></ul><ul><li>Identify an Event </li></ul><ul><li>Locate the Eve...
Identify and Locate. Search the Output to be modified. Search the Tagset for the corresponding Event Search the Output of ...
Finding & Exploring    with Event Map.  ods  tagsets.event_map  file=&quot;map.xml&quot;; < image   event_name =&quot; ima...
Exploring Variables with Putvars.  Put “Event variables” nl; Putvars Event _name_ ': ' _value_ nl; Put “Style variables” n...
Finding Other Useful Events.  Default_Event = putall; Define event putall; put '<' Event_name nl; Putvars Event _name_ ': ...
Using a PutLog event.  Define event putlog; putlog “Event:” event_name nl; Putlog “Name is” “:” name; Putlog “Count is”  “...
Locating Alfred < branch   event_name =&quot;branch&quot;  trigger_name =&quot;attr_out&quot;  class =&quot;ByContentFolde...
A Solution. proc template; define tagset tagsets.gifs2; define event branch; set $name scan(label, 2, '=');  end; define e...
 
Useful Links   <ul><li>ODS Markup, New Tagsets, Howto's. </li></ul><ul><li>http://support.sas.com/rnd/base/topics/odsmarku...
Upcoming SlideShare
Loading in...5
×

Ods Markup And Tagsets: A Tutorial

4,398

Published on

This presentation by Eric Gebhart is an excellent tutorial on SAS ODS markup and tagsets which can be used for arranging SAS reporting output in most any format. Great for creating dashboards too!

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,398
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
73
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Ods Markup And Tagsets: A Tutorial

  1. 1. ODS Markup and Tagsets, A tutorial. Eric Gebhart
  2. 3. ODS MARKUP!
  3. 4. ODS Markup & Tagsets
  4. 6. Proc Template. It is NOT what you think it is!
  5. 7. Tagsets are ODS Destinations ODS Markup tagset=HTML4 .... ODS Tagsets.HTML4 .... ODS HTML4 .... ODS HTML ....
  6. 8. ODS HTML is ODS Markup!
  7. 9. ods tagsets.short_map file = &quot;body.xml&quot; frame = &quot;frame.xml&quot; contents = &quot;contents.xml&quot; pages = &quot;pages.xml&quot; code = &quot;code.xml&quot; data = &quot;data.xml&quot; stylesheet = &quot;stylesheet.xml&quot;; ods _all_ close; The ODS Markup Statement
  8. 10. Special, Named Destinations. <ul><li>HTML, PHTML, HTMLCSS, HTML4, CHTML </li></ul><ul><li>CSV, CSVByline, CSVAll </li></ul><ul><li>LaTeX, Troff </li></ul><ul><li>XML, SASReport, DocBook </li></ul><ul><li>IMode </li></ul>
  9. 11. What is Different ? One more output file. Stylesheet Behavior. More Options.
  10. 12. The same options as before. Ods html file='test.html' ( headtext ='<meta text=”my headtext”>', metatext ='text=”my meta text”, url =' http://www.sas.com/test.html ' ) newfile =table;
  11. 13. Multiple Stylesheet URL's! ODS html file = ”test.html” stylesheet = ”test.css” (url=” test.css corp.css corpnav.css ”);
  12. 14. Multiple Personality Disorder. Ods tagsets.myhtml file=”test.html” Alias=”NoNotes”;
  13. 15. Make up your own Options! ODS tagsets.test file=”test.txt” options ( embedded_titles = 'yes' Orientation = 'landscape' Doc = 'Help');
  14. 16. Options inside the tagset. define tagset tagsets.test; define event initialize; putvars $options _name_ ': ' _value_ nl; end; end;
  15. 17. The tagset Output. EMBEDDED_TITLES: yes ORIENTATION: landscape DOC: Help
  16. 18. One more method of control! ODS tagsets.htmlpanel file = ”test.html”; ODS tagsets.htmlpanel event = panel(start); ... ... ODS tagsets.htmlpanel event = panel(finish); ODS tagsets.htmlpanel close;
  17. 19. ODS Markup is like ODS HTML, PLUS!
  18. 20. Getting a list Proc template; list tagsets; Listing of: SASHELP.TMPLMST Path Filter is: Tagsets Sort by: PATH/ASCENDING Obs Path Type 1 Tagsets Dir 2 Tagsets.Chtml Tagset 3 Tagsets.Colorlatex Tagset 4 Tagsets.Csv Tagset
  19. 21. The HTML Family <ul><li>Phtml </li></ul><ul><li>HtmlCss </li></ul><ul><li>Html4 </li></ul><ul><li>Chtml </li></ul><ul><li>Imode (chtml) </li></ul>
  20. 22. PHTML, Plain HTML. Simple 12 element Stylesheet No class attributes. No Fancy features.
  21. 23. HTMLCSS. Full Stylesheet Fancy Features
  22. 24. HTML4 is ODS HTML Same as HtmlCSS More like Previous Releases
  23. 25. CHTML - Compact HTML. iSNo Subset of HTML. No Styles. Super Set of Imode.
  24. 26. Data Transport and Excel. CSV, CSVByline, CSVAll PYX MSOffice2K ExcelXP DDE http://support.sas.com/news/feature/04jul/excelsupport.html
  25. 27. CSV &quot;Obs&quot;,&quot;Name&quot;,&quot;Sex&quot;,&quot;Age&quot;,&quot;Height&quot;,&quot;Weight&quot; &quot;1&quot;,&quot;Alfred&quot;,&quot;M&quot;,14,69.0,112.5 &quot;2&quot;,&quot;Alice&quot;,&quot;F&quot;,13,56.5,84.0 &quot;3&quot;,&quot;Barbara&quot;,&quot;F&quot;,13,65.3,98.0
  26. 28. PYX (data -Alfred Atype &quot;string&quot; Ajust &quot;l&quot; Acolcount &quot;1&quot; Acol &quot;2&quot; Asection &quot;body&quot; Aclass &quot;Data&quot; )data
  27. 29. The ExcelXP Tagset!
  28. 30. Publications, Papers, PDF. LaTeX Troff DocBook
  29. 31. LaTeX Tagsets LaTeX SimpleLaTeX TablesOnlyLaTeX
  30. 32. Combined Slide Bars - PDF via LaTeX
  31. 33. Other Miscellaneous Tagsets. ODSStyle Style_Popup Style_Display NamedHTML MVSHTML
  32. 35. Tagsets are Collections of Events
  33. 36. Events Define Actions & Output. define event doc; start: put HTMLDOCTYPE nl; put “<html>” nl; finish: put &quot;</html>&quot; nl; end;
  34. 37. A very simple tagset. proc template; define tagset tagsets.plain ; define event data ; put “Data: “ value nl; end; define event header ; put “Header: “ value nl; end; end; run;
  35. 38. Header: Obs Header: Name Header: Sex Header: Age Header: Height Header: Weight Header: 1 Data: Alfred Data: M Data: 14 Data: 69.0 Data: 112.5 ods tagsets.plain file=&quot;plain.txt&quot;; proc print data=sashelp.class;run; ods tagsets.plain close;
  36. 39. Label, Value Pairs Becomes this: <Table background=&quot;grey&quot; foreground=&quot;blue&quot; cellpadding=&quot;5&quot;> Putq '<Table' ' background=' background; putq 'foreground=' foreground; putq 'cellpadding=' cellpadding; put '>' nl; With no attribute values, it becomes: <Table>
  37. 40. If Statements . Put 'Foreground is blue!' nl /if cmp ('blue', foreground); Put 'Foreground is not red!' nl /if ^ cmp ('red', foreground);
  38. 41. AND and OR, sort of... Put 'Some variables have a value.' nl /if any (background, foreground, cellpadding, value); Put 'All variables have a value.'' nl /if exists (background, foreground, cellpadding, value);
  39. 42. Contains a Substring . Set $myvar “this is random text”; put “myvar has ran” nl /if contains ($myvar, “ran”);
  40. 43. Simple if test, Where clauses . Set $myvar “this is random text”; Set $mytest “True”; put “myvar has length” nl /if $myvar; put “longer than 10” nl /if length($myvar) > 10 break /if $mytest;
  41. 44. Break, Breakif Break /if ^$options; Trigger alternate_event /if $do_something_else; Break /if $do_something_else; Trigger alternate_event /breakif $do_something_else;
  42. 45. A list of images. proc template; define tagset tagsets.gifs ; define event branch ; put label &quot; &quot;; end; define event image ; put url nl; end; end; run;
  43. 46. The Output Name=Alfred temp/gplot.gif Name=Alice temp/gplot1.gif Name=Barbara temp/gplot2.gif
  44. 47. A Prettier Report. proc template; define tagset tagsets.gifs2 ; define event branch ; set $name scan( label , 2, '='); end; define event image ; put url &quot; &quot; $name nl; end; end; run;
  45. 48. Nicer looking Output temp/gplot.gif Alfred temp/gplot1.gif Alice temp/gplot2.gif Barbara
  46. 49. The Set Statement. set $myvar “foreground is” forground ; Always creates a string. Variables always start with $.
  47. 50. The Eval Statement. Eval $count 0; Eval $count $count + 1; set $myvar “this is a test”; Eval $index index($myvar, 'test');
  48. 51. Data Step Functions. Can be used anywhere. Cannot be nested except in where clauses.
  49. 52. Simple Needs, Simple Tagsets.
  50. 53. SQL ??? Create table CLASS (Name varchar(7), Sex varchar(1), Age float, Height float, Weight float); Insert into CLASS(Name, Sex, Age, Height, Weight) Values ('Alfred', 'M', 14, 69.0, 112.5); ... ...
  51. 54. Dictionaries define event type_translations; set $types['string'] 'varchar'; set $types['double'] 'float'; set $types['int'] 'integer'; end; /* column name translation */ define event name_translations; set $name_trans['desc'] 'description'; end;
  52. 55. The Initialize Event define event initialize; trigger type_translations; trigger name_translations; /* types that need widths */ set $types_with_widths['string'] &quot;True&quot;; /* types that need quotes */ set $types_with_quotes['string'] &quot;True&quot;; end;
  53. 56. Creating Lists define event colspec_entry; set $lowname lowcase(name); do /if $name_trans[$lowname]; set $names[] $name_trans[$lowname]; else; set $names[] $lowname; done;
  54. 57. define event table_body; put &quot;Create table &quot; $table_name &quot;(&quot;; eval $i 1; unset $not_first; do /while $i <= $names; /* comma's only after the first name */ put ', ' /if $not_first; put $names[$i] &quot; &quot;; put $columns[$i]; eval $i $i+1; set $not_first &quot;True&quot;; done; put &quot;);&quot; nl; end;
  55. 58. Looping through A Dictionary iterate $types do /while _name_ ; put _name_ “: “ _value_ nl; next $types; done;
  56. 59. XBRL, Data Interchange
  57. 60. Better Stripes.
  58. 61. Counting Rows
  59. 62. Streams . <ul><ul><li>Designated by $$ </li></ul></ul><ul><ul><li>Can hold large amounts of data </li></ul></ul><ul><ul><li>Not limited by memory </li></ul></ul><ul><ul><li>Can be opened, closed and flushed. </li></ul></ul>
  60. 63. Streams by example open junk; put “This goes to junk.” nl; put “ More stuff.” nl; close; open trash; put $$junk 'This goes to trash.'; putstream junk; put “ This goes to trash too.”; open junk; put “ Even more stuff”; close; set $$junk “A completely new junk.”; set $$junk $$junk “ Appending to the end”; unset $$junk
  61. 64. Byline Modification
  62. 65. Repeating Row Headers
  63. 66. Simple Needs, Simple Tagsets.
  64. 67. Slide Bars.
  65. 68. Craeting Slide Bars. proc print data=sashelp.class; var name; var sex; var age; var height / style(data) = slider[just=center tagattr=&quot;slider-80&quot;]; var weight / style(data) = slider[just=center tagattr=&quot;slider-150&quot;]; run;
  66. 69. WebSite Integration
  67. 70. Sashelp.class, My Favorite.
  68. 74. Tagset Inheritance . Define tagset tagsets.SSV ; parent = tagsets.csv ; define event header ; start: put ';' / if ^cmp( COLSTART , &quot;1&quot;); put '&quot;'; put VALUE ; finish: put '&quot;'; end; .....
  69. 75. Tagset Attributes Define tagset tagsets.mytags; map = '<>&'; mapsub = '/&lt;/&gt;/&amp;/'; nobreakspace = '&nbsp;' ; embedded_stylesheet = yes; output_type = html; lognote = “you are using my special tagset”;
  70. 76. Using Options define event options_set ; trigger setup_options; end; define event setup_options; trigger nls_numbers; trigger options_setup ; trigger documentation ; end; ODS tagsets.excelxp options(embedded_titles='yes');
  71. 77. Mvar embedded_titles; define event options_setup ; set $options['test'] &quot;test&quot; /if ^$options; do /if $options ['EMBEDDED_TITLES']; do /if cmp( $options ['EMBEDDED_TITLES'], &quot;yes&quot;); set $embedded_titles &quot;true&quot; ; else; unset $embedded_titles; done; else; do /if cmp(embedded_titles, &quot;yes&quot;); set $embedded_titles &quot;true&quot; ; else; unset $embedded_titles; done; done;
  72. 78. Creating Help and documentation. define event documentation; break /if ^$options; trigger quick_reference /if cmp($options['DOC'], 'quick'); trigger help /if cmp($options['DOC'], 'help'); end; define event help ; putlog &quot;============================== “; putlog “The EXCELXP Tagset Help Text.&quot;; ... trigger quick_reference; end;
  73. 79. Extended Procedural Controls. Eval $count 10; do /while $count < 10; eval $count $count+1; stop /if $count = 9; continue /if $count = 3; put $count nl; else; put “Count was already > 10” nl; done;
  74. 80. Else If do /if $count < 10; put “count is < 10”; nl; else /if $count = 11; put “Count is11” nl; else /if $count = 12; put “Count is 12” nl; else; put “Count is > 12” nl; done;
  75. 81. A process for Tagset Creation <ul><li>Define the goal </li></ul><ul><li>Identify an Event </li></ul><ul><li>Locate the Event Code </li></ul><ul><li>Explore the available variables. </li></ul>
  76. 82. Identify and Locate. Search the Output to be modified. Search the Tagset for the corresponding Event Search the Output of the Event_Map Tagset. Look for convienent events with short_map.
  77. 83. Finding & Exploring with Event Map. ods tagsets.event_map file=&quot;map.xml&quot;; < image event_name =&quot; image &quot; trigger_name =&quot;attr_out&quot; output_name =&quot;Gplot&quot; output_label =&quot;Plot of Weight * Height&quot; index =&quot;IDX&quot; j ust =&quot;c&quot; url =&quot; gplot.gif &quot; />
  78. 84. Exploring Variables with Putvars. Put “Event variables” nl; Putvars Event _name_ ': ' _value_ nl; Put “Style variables” nl; Putvars Style _name_ ': ' _value_ nl; Put “Options” nl; Putvars $Options _name_ ': ' _value_ nl;
  79. 85. Finding Other Useful Events. Default_Event = putall; Define event putall; put '<' Event_name nl; Putvars Event _name_ ': ' _value_ nl; Putvars Style _name_ ': ' _value_ nl; Putvars Mem _name_ ': ' _value_ nl; put '>' Event_name nl; End;
  80. 86. Using a PutLog event. Define event putlog; putlog “Event:” event_name nl; Putlog “Name is” “:” name; Putlog “Count is” “:” $count; end;
  81. 87. Locating Alfred < branch event_name =&quot;branch&quot; trigger_name =&quot;attr_out&quot; class =&quot;ByContentFolder&quot; value =&quot;Name=Alfred&quot; name =&quot;ByGroup1&quot; label =&quot; Name=Alfred &quot; index =&quot;IDX&quot; just =&quot;c&quot; url =&quot;junk.xml#IDX&quot; hreftarget =&quot;body&quot;>
  82. 88. A Solution. proc template; define tagset tagsets.gifs2; define event branch; set $name scan(label, 2, '='); end; define event image; put url &quot; &quot; $name nl; end; end; run;
  83. 90. Useful Links <ul><li>ODS Markup, New Tagsets, Howto's. </li></ul><ul><li>http://support.sas.com/rnd/base/topics/odsmarkup/ </li></ul><ul><li>Introduction to Tagsets. </li></ul><ul><li>http://support.sas.com/rnd/base/topics/odsmarkup/tagsets.html </li></ul><ul><li>The Template FAQ. </li></ul><ul><li>http://support.sas.com/rnd/base/topics/templateFAQ/Template.html </li></ul>[email_address] [email_address]
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×