tagattr is it

97
ODS ExcelXP: Tag Attr Is It! Using and Understanding the TAGATTR= Style Attribute with the ExcelXP Tagset Eric Gebhart, SAS Institute Inc., Cary, NC

Upload: eagebhart

Post on 12-Jun-2015

1.553 views

Category:

Technology


0 download

DESCRIPTION

ODS ExcelXP can be complicated to use, learn how to use all the various features of the very powerful tagattr style option.

TRANSCRIPT

Page 1: Tagattr is it

ODS ExcelXP: Tag Attr Is It! Using and Understanding the TAGATTR= Style Attribute with the ExcelXP Tagset

Eric Gebhart, SAS Institute Inc., Cary, NC

Page 2: Tagattr is it
Page 3: Tagattr is it

TagAttr=’

Page 4: Tagattr is it

Format

Type

Formulas

Rotation

Hidden

Merging

Wrapping

TagAttr=’

Page 5: Tagattr is it
Page 6: Tagattr is it

TagAttr=‘format:ods tagsets.excelxp options(autofilter='All') file="example1.xls" style=journal;

ods tagsets.excelxp close;

Page 7: Tagattr is it

proc print data=sashelp.class contents="sashelp.class";

id Name; var Sex; var Age Height Weight / sum Age Height Weight; run;

ods tagsets.excelxp options(autofilter='All') file="example1.xls" style=journal;

ods tagsets.excelxp close;

style={tagattr='format:##0.0'};

Page 8: Tagattr is it
Page 9: Tagattr is it

The XML

Page 10: Tagattr is it

The Style

The Data Cell

Page 11: Tagattr is it

<Style ss:ID="data__r1" ss:Parent="data__r"><Protection ss:Protected="1" /><NumberFormat ss:Format="##0.0" /></Style>

The Data Cell

Page 12: Tagattr is it

<Style ss:ID="data__r1" ss:Parent="data__r"><Protection ss:Protected="1" /><NumberFormat ss:Format="##0.0" /></Style>

<Cell ss:StyleID="data__r1" ss:Index="3"><Data ss:Type="Number">14</Data></Cell>

Page 13: Tagattr is it
Page 14: Tagattr is it

Tagattr=‘Type:

Page 15: Tagattr is it

data buy;

set sashelp.buy;

datetime=date*86400;

run;

Page 16: Tagattr is it

ods tagsets.excelxp file='example5.xls' style=analysis;

ods tagsets.excelxp close;

Page 17: Tagattr is it

proc print data=buy;

format datetime e8601dt.;

var datetime / style(data)={tagattr='type:DateTime

format:YYYY-MM-DD'};

var date;

var amount;

run;

ods tagsets.excelxp file='example5.xls' style=analysis;

ods tagsets.excelxp close;

Page 18: Tagattr is it
Page 19: Tagattr is it

Date String

Page 20: Tagattr is it
Page 21: Tagattr is it

The Style

The XML

The Data Cells

Page 22: Tagattr is it

<Style ss:ID="data__r1" ss:Parent="data__r"><Protection ss:Protected="1" /><NumberFormat ss:Format="YYYY-MM-DD" /></Style>

The XML

The Data Cells

Page 23: Tagattr is it

<Style ss:ID="data__r1" ss:Parent="data__r"><Protection ss:Protected="1" /><NumberFormat ss:Format="YYYY-MM-DD" /></Style>

The XML<Cell ss:StyleID="data__r1" ss:Index="2"><Data ss:Type="DateTime">1996-01-01T00:00:00</Data></Cell>

<Cell ss:StyleID="data__r" ss:Index="3"><Data ss:Type="String">01JAN1996</Data></Cell>

Page 24: Tagattr is it
Page 25: Tagattr is it

TagAttr='formula:

Page 26: Tagattr is it

TagAttr='formula:proc print data=test noobs label split='*'; var camp_code ... ... ... ... ... roi_profit;

var roi_cost / style={tagattr='formula:RC[-1]*0.25'}; var roi_value / style={tagattr='format:0% formula:RC[-2]/RC[-1]'}; sum offers / style={tagattr='format:#,###'}; sum obj_value roi_profit roi_cost;run;

Page 27: Tagattr is it
Page 28: Tagattr is it

The XML

Page 29: Tagattr is it

The Data Cells

Page 30: Tagattr is it

<Cell ss:StyleID="data__r_1" ss:Formula="rc[-1]*0.25"><Data ss:Type="Number">222.91</Data></Cell>

<Cell ss:StyleID="data__r_2" ss:Formula="RC[-2]/RC[-1]"><Data ss:Type="Number">4</Data></Cell>

Page 31: Tagattr is it
Page 32: Tagattr is it

TagAttr='rotate:

Page 33: Tagattr is it

proc template; define style styles.myjournal; parent = styles.Journal; style angle_header from header / tagattr = 'rotate:45' ; end; run;

Page 34: Tagattr is it

ods tagsets.ExcelXP file="example4.xls" style=myjournal;

proc template; define style styles.myjournal; parent = styles.Journal; style angle_header from header / tagattr = 'rotate:45' ; end; run;

ods tagsets.ExcelXP close;

Page 35: Tagattr is it

ods tagsets.ExcelXP file="example4.xls" style=myjournal;

proc tabulate data=foo order=data missing format=8.0 noseps formchar=', '; by sex; class age sex name; var height weight; title; table age, name=' '*(height=' '*median=' '*F=5.3);

run;

ods tagsets.ExcelXP close;

classlev name /s=angle_header;

Page 36: Tagattr is it
Page 37: Tagattr is it

The XML

Page 38: Tagattr is it

The Style

Page 39: Tagattr is it

<Style ss:ID="angle_header" ss:Parent="table"><Alignment ss:WrapText="1" ss:Rotate="45"/>

<Font ss:FontName="Arial, Helvetica, Helv" ss:Size="10" ss:Italic="1" ss:Color="#000000" />

<Interior ss:Color="#FFFFFF" ss:Pattern="Solid" /><Protection ss:Protected="1" /></Style>

Page 40: Tagattr is it
Page 41: Tagattr is it

TagAttr='hidden:

Page 42: Tagattr is it

proc template; define style styles.mymeadow; parent=styles.meadow;

style hidden from data/ tagattr="hidden:yes" ;end;run;

Page 43: Tagattr is it

ods tagsets.excelxp file="example5.xls" style=mymeadow;

ods _all_ close;

Page 44: Tagattr is it

proc report data=sashelp.class nowd; column Name Sex Age Weight Height; define Weight / display;

compute Weight; if (Weight > 100) then do; CALL DEFINE(_ROW_, "STYLE", "STYLE=hidden"); end; endcomp; run;

ods tagsets.excelxp file="example5.xls" style=mymeadow;

ods _all_ close;

Page 45: Tagattr is it
Page 46: Tagattr is it

Hidden

Page 47: Tagattr is it

The XML

Page 48: Tagattr is it

The Data Row

Page 49: Tagattr is it

<Row ss:AutoFitHeight="1" ss:Hidden="1" ss:Height="15">

<Cell ss:StyleID="hidden" ss:Index="1"><Data ss:Type="String">William</Data></Cell>

<Cell ss:StyleID="hidden" ss:Index="2"><Data ss:Type="String">M</Data></Cell><Cell ss:StyleID="hidden" ss:Index="3"><Data ss:Type="Number">15</Data></Cell><Cell ss:StyleID="hidden" ss:Index="4"><Data ss:Type="Number">112</Data></Cell><Cell ss:StyleID="hidden" ss:Index="5"><Data ss:Type="Number">66.5</Data></Cell>

</Row>

Page 50: Tagattr is it
Page 51: Tagattr is it

TagAttr="mergeAcross:

Page 52: Tagattr is it

TagAttr="mergeAcross:

data test; d1 = '1st data row of stuff'; output; d1 = '2nd data row of stuff'; output;run;

Page 53: Tagattr is it

data test; d1 = '1st data row of stuff'; output; d1 = '2nd data row of stuff'; output;run;

ods tagsets.excelxp file="example6.xls" style=journal ;

ods tagsets.excelxp close;

Page 54: Tagattr is it

style={tagattr="mergeAcross:yes"};

proc report data=test nowd; columns d1; define d1 / '' run;

data test; d1 = '1st data row of stuff'; output; d1 = '2nd data row of stuff'; output;run;

ods tagsets.excelxp file="example6.xls" style=journal ;

ods tagsets.excelxp close;

Page 55: Tagattr is it

proc report data=test nowd; columns d1; define d1 / '' run;

;

data test; d1 = '1st data row of stuff'; output; d1 = '2nd data row of stuff'; output;run;

ods tagsets.excelxp file="example6.xls" style=journal ;

ods tagsets.excelxp close;

Page 56: Tagattr is it
Page 57: Tagattr is it

The XML

Page 58: Tagattr is it

The Regular Cell

The Merged Cell

Page 59: Tagattr is it

The Regular Cell

<Cell ss:StyleID="data__l" ss:MergeAcross="1" ss:Index="1"><Data ss:Type="String">1st data row of stuff</Data></Cell>

Page 60: Tagattr is it

<Cell ss:StyleID="data__l" ss:MergeAcross="1" ss:Index="1"><Data ss:Type="String">1st data row of stuff</Data></Cell>

<Cell ss:StyleID="data__l" ss:Index="1"><Data ss:Type="String">1st data row of stuff</Data></Cell>

Page 61: Tagattr is it
Page 62: Tagattr is it

TagAttr='wrap:

Page 63: Tagattr is it

TagAttr='wrap:

ods _all_ close;

ods tagsets.excelxp file="example7.xls" style=mymeadow options(wraptext='no');

Page 64: Tagattr is it

ods _all_ close;

ods tagsets.excelxp file="example7.xls" style=mymeadow options(wraptext='no');

proc report data=sashelp.class nowd; column Name Sex Age Weight Height; define Weight / display;

compute Weight; if (Weight > 100) then do; CALL DEFINE(_ROW_, "STYLE", end; endcomp; run;

"STYLE=data[tagattr='wrap:yes']");

Page 65: Tagattr is it
Page 66: Tagattr is it

The XML<Style ss:ID="data__l

<Alignment

</Style>

ss:WrapText="1" ss:Horizontal="Left"/>

" ss:Parent="data">

The Usual Data Left

Page 67: Tagattr is it

The XML<Style ss:ID="data__l

<Alignment

</Style>

ss:Horizontal="Left"/>

" ss:Parent="data">

The No Wrap Data Left

Page 68: Tagattr is it

The XML<Style ss:ID="data__l

<Alignment

</Style>

ss:Horizontal="Left"/>

" ss:Parent="data">

The Wapping Data Left Over Ride

r

ss:WrapText="1"

Page 69: Tagattr is it
Page 70: Tagattr is it

<Style ss:ID="data" ss:Parent="table">

.....

<Protection ss:Protected="1" /><NumberFormat ss:Format="General" /></Style>

More XML

The Usual Data Style

ss:WrapText="1" /><Alignment

Page 71: Tagattr is it

<Style ss:ID="data" ss:Parent="table">

.....

<Protection ss:Protected="1" /><NumberFormat ss:Format="General" /></Style>

More XML

The No Wrap Style

Page 72: Tagattr is it
Page 73: Tagattr is it

Too Much XML!

The Data Cell

<Cell ss:StyleID="data__l1" ss:Index="1"><Data ss:Type="String">Alfred</Data></Cell>

Page 74: Tagattr is it

TagAttr=’

Page 75: Tagattr is it

Format

Type

Formulas

Rotation

Hidden

Merging

Wrapping

TagAttr=’

Page 76: Tagattr is it

Tagattr Processing

Page 77: Tagattr is it

Tagattr Processing

Page 78: Tagattr is it

Building a list of attrs

Page 79: Tagattr is it

Building a list of attrs

Page 80: Tagattr is it

Normalize the Attrs

Page 81: Tagattr is it

Normalize the Attrs

Page 82: Tagattr is it

Normalize the Attrs

Page 83: Tagattr is it

Normalize the Attrs

Page 84: Tagattr is it

Normalize the Attrs

Page 85: Tagattr is it

Hiding & Wrapping

Page 86: Tagattr is it

Hiding & Wrapping

Page 87: Tagattr is it

Hiding & Wrapping

Page 88: Tagattr is it

Creating the Style

Page 89: Tagattr is it

Creating the Style

Page 90: Tagattr is it

Creating the Style

Page 91: Tagattr is it

Creating the Style

Page 92: Tagattr is it

Creating the Style

Page 93: Tagattr is it

Creating the Style

Page 94: Tagattr is it

Formulas in the Cell

Page 95: Tagattr is it

Formulas in the Cell

Page 96: Tagattr is it
Page 97: Tagattr is it

Copyright © 2010, SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

Copyright © 2010, SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

Eric GebhartAsheville, NC.E-mail: [email protected]: http://EricGebhart.com