get fancy department level reports using sas excelxp tagset 2008 air forum seattle, washington ray...
Post on 21-Dec-2015
219 views
TRANSCRIPT
![Page 1: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/1.jpg)
Get Fancy Department Level
Reports Using SAS ExcelXP Tagset
2008 AIR Forum
Seattle, Washington
Ray Wallace ([email protected])
Washington State University
View Presentation at
http://www.ir.wsu.edu/
![Page 2: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/2.jpg)
Presentation Overview
• SAS Tagsets (Excel features from SAS)
• Style (Get it to look right)
• Department Looping (Macros)
![Page 3: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/3.jpg)
What is a Tagset?
• Adds ‘tags’ to output using ODS
• Ex. HTML tag: <body>Put Body of Web Page Here</body>
• ExcelXP tagset uses xml tags, Ex.
<Row><Cell><Data> data in the
cell</Data></Cell></Row>
• Developed by Eric Gebhart from SAS
• Get the latest tagset code• http://support.sas.com/rnd/base/ods/odsmarkup/index.html• New version 1.86 available as of April 2008
![Page 4: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/4.jpg)
Install the Latest Tagset
• Download the latest version from support.sas.com
• Save the *.tpl file
• Open the *.tpl file in SAS
• Run it
ExcelXP Tagset Code
![Page 5: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/5.jpg)
How Does A Tagset Work?
A Tagset is just another ODS destination.
E.g.,
• listing
• html
• Tagsets (such as ExcelXP)
![Page 6: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/6.jpg)
How Does A Tagset Work?
Things you can do to an ODS Destination
• Open ods tagsets.ExcelXP file=‘foo.xls’;
• Manage ods tagsets.ExcelXP
options(embedded_titles=‘yes’);
• Close ods tagsets.ExcelXP close;
![Page 7: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/7.jpg)
Get A List Of The Available Tagsets
proc template;list tagsets;run;
User-defined tagsets will be located in SASUSER.TEMPLAT.User-defined tagsets will be located in SASUSER.TEMPLAT.Tagsets provided by SAS are in SASHELP.TMPLMSTTagsets provided by SAS are in SASHELP.TMPLMST
![Page 8: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/8.jpg)
How Does Style Work?
Works with the ODS
Define with proc template
When issuing an ODS command style is impliedEx:
ods tagsets.excelxp file = ‘foo.xls’; is the same as
ods tagsets.excelxp file = ‘foo.xls’ style = default;
![Page 9: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/9.jpg)
Get A List Of The Styles You Have
proc template; list styles;run;
Just like tagsets…User-defined styles will be in SASUSER.TEMPLAT
Styles provided by SAS are in SASHELP.TMPLMST
![Page 10: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/10.jpg)
Make Your Own Style
Find a style you like then ‘tweek’ it a little.
proc template; source styles.default; run;
![Page 11: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/11.jpg)
Easy To Create Your Own Style
Use inheritance then add your own twists
proc template;define style irstyle_xl; parent = styles.default; style systemtitle from systemtitle /
background=white foreground=cx990033 end;
Style Element
Inheritance
![Page 12: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/12.jpg)
Building a Report
• Department Level Accreditation Data• Want a consolidated and concise report of information from
various topic areas• Display multiple years of data• Easy for users to read• Familiar format (Excel)• Metadata/data definitions• Extensible (able to add reports easily)• Printable
![Page 13: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/13.jpg)
ExcelXP Options
Over 60 options and controls allow SAS to control Excel. Including…• Table of Contents/Index• Customizing column widths• Zooming• Header / footer control• Excel comments• Repeat cells• Sheet naming• Page orientation
Get Documentation:ods Tagsets.ExcelXP file = "c:\test.xls” options (doc='help') ;
ods tagsets.Excelxp close ;
![Page 14: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/14.jpg)
ExcelXP Options
Determine the zoom level on the worksheetods tagsets.excelxp options (zoom=’88’) ;
‘100’ is the default
![Page 15: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/15.jpg)
ExcelXP Options
Repeat header row on each page for printing ods tagsets.excelxp options(row_repeat=‘header’);
Also Use these options‘none’ -default‘1-3’ ‘5’
![Page 16: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/16.jpg)
ExcelXP Options
Create a sheet which has links names of all other worksheets. ods tagsets.excelxp options(index=‘yes’);
![Page 17: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/17.jpg)
ExcelXP Options
Name the worksheetsods tagsets.excelxp options (sheet_name=‘Overview Data’)
Could use a macro var“&dept”
![Page 18: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/18.jpg)
ExcelXP Options
When to create a new sheetods tagsets.excelxp options (sheet_interval=’proc’) ;
‘Table’ is the default
Also use ‘page’, ‘ bygroup’, ‘proc’, ‘none’
![Page 19: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/19.jpg)
ExcelXP Options
Format the page for printing ods tagsets.excelxp options (orientation=‘landscape’);
![Page 20: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/20.jpg)
ExcelXP Options
Tells Excel the width of each columnods tagsets.excelxp options (default_Column_Width=‘12,9,6,6,6,6,6,8’);
![Page 21: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/21.jpg)
ExcelXP Style Options
Use the currency format from Excel.In the proc report, proc print etc.
define fy2003 / analysis style(column)={tagattr="format:$#,##0_);[Red]($#,##0)"};
Others:‘format:##0.0%’ ‘format:##0.00’
![Page 22: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/22.jpg)
Using Style
Using proc format with Excel comments
First…proc format ;value $subjdesc
‘MATH’=‘Mathematics’‘GENED’=‘General Education’
...more subject formats... ;
• Then…
![Page 23: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/23.jpg)
ExcelXP Style Options
Print comments in the appropriate cells down the column
define prefix / group ‘Prefix‘style(column)={flyover=$subjdesc.} ;
Or explicitly define {fylover=‘Hello World’}
![Page 24: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/24.jpg)
Three Levels of Style Hierarchy
1. Document level (ods statement)
ods tagsets.ExcelXP file = “c:\Report for &dept..xls”style=irstyle_xl;
![Page 25: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/25.jpg)
Three Levels of Style Hierarchy
2. Procedure level (proc report statement)
proc report data=sashelp.classstyle(header)={font_weight=bold};
![Page 26: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/26.jpg)
Three Levels of Style Hierarchy
3a. Variable level – e.g., define statement under proc report.
define taught_to / group style(column)={flyover=$ownother.};
![Page 27: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/27.jpg)
Three Levels of Style Hierarchy
3b. Variable level - break and rbreak statement in proc report
rbreak after / ol summarize style(summary)=Total;
Total is a style element defined in the irstyle_xl.
style total from summary / flyover = ‘’
font_style = italic;
![Page 28: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/28.jpg)
Two Levels of Style Specificity
Two levels of specificity
1. Style definition reference
style(header)=hrheader (predefined in irstyle_xl)
2. Direct
style(column)={font_size=2}
![Page 29: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/29.jpg)
Macro Looping
To have your program create an Excel file for each academic department…
Use a macro!%macro deptloop(dept);
…SAS CODE…
%mend deptloop;
%deptloop(CHEM)
![Page 30: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/30.jpg)
Macro Looping
What goes in the …SAS CODE… portion of the program?
First open the ODS destination and manage options for the first report.
ods tagsets.ExcelXP file = “c:\Report for &dept..xls”style=irstyle_xloptions (sheet interval=‘proc’
sheet_name=‘First dept report’);
![Page 31: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/31.jpg)
Macro Looping
What goes in the …SAS CODE… portion of the program?
Then maybe some traffic lighting…
proc format;value traffic
low - <10 = ‘red’ 10 - <50 = ‘yellow’ 50 - high = ‘green’
![Page 32: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/32.jpg)
Macro Looping
What goes in the …SAS CODE… portion of the program?
Now, the first report using proc print.
proc print data = deptreport1 ; var subject / style(column)={flyover=$subjdesc.}; var headcount / style(header)={background=cxD99795} style(column)={background=traffic.};where dept = “&dept”;run;
![Page 33: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/33.jpg)
Macro Looping
What goes in the …SAS CODE… portion of the program?
Use ExcelXP options again for the next report
ods tagsets.ExcelXP options(sheet_name=‘Second Dept Report‘ default_Column_Width=’12,6,6,6,6,6’); frozen_header=‘2’);
![Page 34: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/34.jpg)
Macro Looping
What goes in the …SAS CODE… portion of the program?
Write the second report.
proc report data = deptreport2 nowd missing ; column subject acad_year, fte; define subject/ group ‘Course Subject’; define acad_year / across ‘AY’ define fte /analysis sum ‘FTE’
style(column)={tagattr="format:##0.0“}; where dept = “&dept”;run;
![Page 35: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/35.jpg)
Macro Looping
What goes in the …SAS CODE… portion of the program?
Now finish it up.
ods tagsets.ExcelXP close;
This closes the ODS and finishes creating the Excel file.
Then the macro must end and...
%mend deptloop; SAS must call the macro for the code to actually run.
%deptloop(CHEM)
![Page 36: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/36.jpg)
Macro Looping
What if you have 100+ department and don’t want to write 100+ %deptloop() macro calls?
create macro var for a percent sign%let pctsign=%str(%%);
This will write all your macro calls for youdata _null_ ; set dept_list ; end = lastobs; file "c:\call the macro program.txt"; put "&pctsign" "deptloop (" dept +(1*-1) ")" ;
run;
This will run all your macro calls for you%include "c:\ call the macro program.txt" ;
![Page 37: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/37.jpg)
Question?
Contact me at…Ray Wallace ([email protected])
Washington State University
View Presentation at
http://www.ir.wsu.edu/
![Page 38: Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace (rwallace@wsu.edu) Washington State University](https://reader036.vdocuments.mx/reader036/viewer/2022062516/56649d5a5503460f94a3aebe/html5/thumbnails/38.jpg)
ResourcesSAS-L newsgroupSAS emits SAS tech support
Tagset Linkshttp://support.sas.com/events/sasglobalforum/index.htmlhttp://support.sas.com/rnd/base/ods/odsmarkup/
Style Linkshttp://www.laurenhaworth.com/publications/195-28.pdfhttp://www.laurenhaworth.com/publications/132-30.pdfhttp://www.guptaprogramming.com/images/ODS_Custom.pdf