ODS for PRINT REPORT and TABULATE.docx
- 文档编号:12289314
- 上传时间:2023-04-17
- 格式:DOCX
- 页数:25
- 大小:143.71KB
ODS for PRINT REPORT and TABULATE.docx
《ODS for PRINT REPORT and TABULATE.docx》由会员分享,可在线阅读,更多相关《ODS for PRINT REPORT and TABULATE.docx(25页珍藏版)》请在冰豆网上搜索。
ODSforPRINTREPORTandTABULATE
ODSforPRINT,REPORTandTABULATE
LaurenHaworth,Genentech,Inc.,SouthSanFrancisco
ØAbstract
FormostproceduresintheSASsystem,theonlywaytochangetheappearanceoftheoutputistochangeormodifytheODSstyledefinition.Therearethreeexceptions:
PRINT,REPORT,andTABULATE.Theseproceduresallowyoutochangetheoutputstyleattributesontheflywhentheoutputisgenerated.
Withthesethreeprocedures,youcancreatealmostanytypeoftabularreport.Addintheextracontroloverstyleattributes,andyouhaveareportingpowerhouse.
Thispaperwillshowhowtochangethefonts,colors,andalignmentofyouroutput.Youwillalsolearnhowtouseformatstohighlightkeyresultsinspecialcolorsanduseimagesintableheadings.
Forconvenience,alloftheexamplesareshownasHTMLoutput.Exceptwherenoted,theexamplesallworkforRTForPDFoutputaswell.
TheexamplesinthispaperarebasedonSASversion9.1.3,thoughmostofthesefeatureswereavailablestartingwithversion8.
ØIntroduction
Thisfirstseriesofexampleswillshowhowyoucanusestyleattributestomodifytheappearanceoftheresulttableheadings.Laterexampleswillshowtechniquesforrowsandtablevalues.
TheSTYLE=optionisonlyavailableforthePRINT,REPORT,andTABULATEprocedures.Whatitallowsyoutodoistospecifyanumberofdifferentstyleattributesforspecificpartsofyouroutput.Thesestyleattributescontrolthingsliketypefaces,foregroundandbackgroundcolors,textalignment,andtableborders.
ØExample#1:
ChangingTableHeadingStylesforPROCPRINT
ApplyingstyleattributestoPROCPRINToutputisverysimple.AllyouhavetodoisaddSTYLE=optionstowhicheverpartoftheoutputyouwishtochange.
ThereareanumberofwaysyoucanuseSTYLE=inthePRINTprocedure.Tokeepthingssimple,we’lljustlookatonetechnique:
addingaSTYLE=optiontothePROCPRINTstatement.We’llstartwiththefollowingcode.Itproducesalistingofthreevariables.
ODSHTMLFILE='tables.htm';
procprintdata=tablesnoobslabel;
varTypeMaterialPrice;
run;
ODSHTMLCLOSE;
Thiscodeproducestheoutputshownbelow.It’sabasictableusingtheDefaultstyledefinition(onlythefirstfewrowsofthetableareshown).
ThetypefaceusedintheheadingsandtablebodyisArial.Asanexample,wewillchangethistypefacetoArialNarrow,whichwillmaketheheadingsnarrower.Thisisusefulifyouhaveatablethatistoowidetofitonthepage.
WedothisbyaddingaSTYLE=optiontothePROCPRINTstatement.TheSTYLEkeywordisfollowedbythenameofthestyleelementwewishtomodify.Inthiscase,theelementiscalledHeader.AlistoftheelementsyoucanmodifyisintheOnlineDocumentationforthePRINTprocedure.
Thestyleelementislistedinparentheses.Followingthenameofthestyleelement,weuseanequalsignandthenlisttheattributewewishtochange.DetaileddocumentationontheseattributesandtheirsettingscanbefoundintheOnlineDocumentation.
Theattributemustbecontainedbetweensquarebrackets“[]”orcurlybrackets“{}”.ThecodebelowchangesthefonttypefacetoArialNarrow.Noticetheuseofquotesaroundthetypefacename.Because‘ArialNarrow’containsspaces,thesequotemarksarenecessary.
ODSHTMLBODY='tables.htm';
procprintdata=tablesnoobslabel
STYLE(Header)=[FONT_FACE=’ArialNarrow’];
varTypeMaterialPrice;
run;
ODSHTMLCLOSE;
Theresultsareshownbelow.Noweachofthetableheadingstakesuplesswidth.Thismakestheoveralltablenar
rower,allowingyoutofitmoreinformationonthepage(orscreen).Thistechniquecanbeusedtochangeanyofthecolumnheadingattributes.
ØExample#2:
ChangingTableHeadingStylesforPROCREPORT
Next,we’llrunthroughthesamecolumnheadingmodificationforPROCREPORToutput.We’llstartwithatablesimilartothepreviousexample.
ODSHTMLBODY='tables.htm';
procreportdata=tablesnowd;
columnTypeMaterialPrice;
defineType/group;
defineMaterial/group;
definePrice/analysismean;
run;
ODSHTMLCLOSE;
Thiscodeproducestheoutputshowninbelow.It’sabasictableusingtheDefaultstyledefinition,andisverysimilartothePROCPRINTtablewemodifiedearlier.
Onceagain,we’regoingtochangetheheadingfont.WedothiswiththeexactsametechniqueasweusedforPROCPRINT.WeaddaSTYLE(Header)=optiontothePROCREPORTstatement.
ODSHTMLBODY='tables.htm';
procreportdata=tablesnowd
STYLE(Header)=[FONT_FACE=’ArialNarrow’];
columnTypeMaterialPrice;
defineType/group;
defineMaterial/group;
definePrice/analysismean;
run;
ODSHTMLCLOSE;
Thenewresultsareshownbelow.Again,wegetatablewithnarrowerheadings.Thistechniquecanbeusedtochangeanyofthecolumnheadingattributes.
ØExample#3:
ChangingTableHeadingStylesforPROCTABULATE
Toroundouttheseexamples,we’llrunthroughmakingthesamechangeforatableproducedbyPROCTABULATE.
Onceagain,wewilladdaSTYLE=optiontothepartoftheoutputwewishtochange.We’llstartwithatablesimilartothepreviousexamples.
ODSHTMLBODY='tables.htm';
proctabulatedata=tablesf=dollar8.;
classTypeMaterial;
varPrice;
tableType*Material,
Price*Mean="";
run;
ODSHTMLCLOSE;
Thiscodeproducestheoutputshownbelow.It’sabasictableusingtheDefaultstyledefinition,andisverysimilartotheprevioustablescreatedwithPRINTandREPORT.
Thistime,insteadofaddingaSTYLE(Header)=optiontothemainprocedurecall,weneedtodothingsvariablebyvariable.WithTABULATE,youspecifystylesfortherowandcolumnheadingsintheVARandCLASSstatementsthatidentifythevariables.
ODSHTMLBODY='tables.htm';
proctabulatedata=tablesf=dollar8.;
classTypeMaterial/
STYLE=[FONT_FACE="ArialNarrow"];
varPrice/
STYLE=[FONT_FACE="ArialNarrow"];
tableType*Material,
Price*Mean="";
run;
ODSHTMLCLOSE;
Theresultsareshownbelow.Noticehowthethreetopheadingsnowshowthenewnarrowerfont.However,therowheadingsdonotshowthesamechange.Thisisbecausethesearetheclasslevelvalueheadings,nottheclassvariableheadings.
Tomakealloftheheadingsmatch,weneedtoaddonemorestatementtoourcode.TheCLASSLEVstatementisusedtoapplyoptionstoclasslevelvalues.YoucanusetheSTYLE=optionontheCLASSLEVstatementtochangethefontstomatchthetopheadings.
ODSHTMLBODY='tables.htm';
proctabulatedata=tablesf=dollar8.;
classTypeMaterial/
STYLE=[FONT_FACE="ArialNarrow"];
classlevTypeMaterial/
STYLE=[FONT_FACE="ArialNarrow"];
varPrice/
STYLE=[FONT_FACE="ArialNarrow"];
tableType*Material,
Price*Mean="";
run;
ODSHTMLCLOSE;
Thenewresultsareshownbelow.
Thistechniquecanbeusedtochangeanyoftheroworcolumnheadings.Youcanalsousedifferentstyleattributesforeachclassificationvariable,bycreatingmultipleCLASSandCLASSLEVstatements,onesetfor“Type”andonesetfor“Material”.ThenyoucoulduseadifferentSTYLE=optionforeachvariable.Thesametechniquealsoworkswhenyouhavetwoanalysisvariables,youcanusetwoVARstatementswithtwodifferentSTYLE=options.
ØExample#4:
ApplyingTrafficLightingtoPROCPRINTResults
WhatdotrafficlightshavetodowithSASOutput?
Theansweristhatthefamiliarred,yellow,andgreenlightscanbeusedtohighlightresultsinyouroutput.Youuseredforbadresults,yellowforneutralresults,andgreenforgoodresults.Ifyou’recreatingalargetable,thistechniqueisgreatforfocusingthereader’sattentiononthekeyresults.
Inthisexample,wewilltakeourfamiliartableandusetrafficlightingtomarklowpricesingreen,highpricesinred,andpricesinbetweeninyellow.
Thefirststepistosetupaformatwiththecolorswe’dliketouse.
procformat;
valuetrafficlow-100='green'
100<-300='yellow'
300<-high='red';
run;
Thenextstepistosetupthecodeforthetable,andthenapplytheformat.Thecodeisshownbelow.
ODSHTMLFILE='tables.htm';
procprintdata=tablesnoobslabel;
varTypeMaterial;
varPrice/
STYLE=[BACKGROUND=traffic.];
run;
ODSHTMLCLOSE;
It’sthesamecodefromourpreviousexample.TheonlydifferenceisthattheVARstatementhasbeensplitintotwostatements.That’ssotheSTYLE=optioncanbeappliedtojustthevariablePrice.ThestyleattributewearemodifyingisBACKGROUND,whichcontrolsthebackgroundcolor.
Youcouldjustspecifyasinglebackgroundcolorhere,suchas“Red”,whichwouldmaketheentirecolumnofresultsred.Instead,wewilluseourformat.Thisallowsustohaveaconditionalbackgroundcolor.Dependingonthevalueofeachtablecell,thebackgroundwillbesetasgreen,yelloworred.Theresultsareshownbelow.
Nowthelowpricesshowupingreen,thehighpricesinred,andtheonesinbetweenareinyellow.However,withthesedarkbackgrounds,thepricevaluesgetabithardtoread.Thedefaultfontweightisabitlightfortheseintensebackgrounds.Tofixthat,we’llmakethefontsbold,asshowninthecodebelow.
ODSHTMLFILE='tables.htm';
procprintdata=tablesnoobslabel;
varTypeMaterial/
STYLE=[FONT_WEIGHT=BOLD];
varPrice/
STYLE=[BACKGROUND=traffic.
FONT_WEIGHT=BOLD];
run;
ODSHTMLCLOSE;
ThefontischangedtoboldinbothVARstatementssothatthetablewilllookconsistent.Thenewoutputisshownbelow.
Bytheway,youcanalsodotrafficlightingbychangingtheforegroundvalues.Insteadofmakingthecellbackgroundred,yellow,orgreen,youcanmakethecelltextred,yellow,orgreen.Thecodeisthesame,exceptinsteadofusingBACKGROUND=intheSTYLE=option,youuseFOREGROUND=.
Ø
Example
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ODS for PRINT REPORT and TABULATE