Generating Reports.docx
- 文档编号:24572937
- 上传时间:2023-05-29
- 格式:DOCX
- 页数:30
- 大小:26.24KB
Generating Reports.docx
《Generating Reports.docx》由会员分享,可在线阅读,更多相关《Generating Reports.docx(30页珍藏版)》请在冰豆网上搜索。
GeneratingReports
Topic:
GeneratingReports
1.GeneratingreportsusingthePRINTprocedure
2.GeneratingfrequencytablesusingPROCFREQprocedure
3.GeneratingreportusingMEANSprocedure
4.GeneratingreportusingREPORTprocedure
5.Enhancingreportthroughtheuseoflabels,SASformat,titles,footnotesandSASSystemreportingoptions
6.IntroductiontoODS
1.PROCPRINT
PROCPRINTliststhevaluesofthevariablesinaSASdatasetintheoutputwindow.ThePROCPRINTprocedureyouareabletouseprintstheobservationsinaSASdataset,usingallorsomeofthevariables.Youcancreateavarietyofreportsrangingfromasimplelistingtoahighlycustomizedreportthatgroupsthedataandcalculatestotalsandsubtotalsfornumericvariables.
TheVARstatementtellsSAStoprintonlythevariableslistedandintheordergiven.
∙PrintsalistingofthevaluesofsomeorallofthevariablesinaSASdataset.
∙ThePRINTprocedurecanbecontrolledbythefollowingstatements:
oPROCPRINToptions;
oIDvariable-list;
oVARvariable-list;
oBYvariable-list;
oPAGEBYby-variable;
oSUMBYby-variable;
oSUMvariable-list;
∙UsefulOptions...
oDouble-doublespacestheprintedoutput.
oLabel-usesvariablelabelsascolumnheadings(variablenameisdefaultheading).
oNoobs-suppressestheobservationnumberintheoutput.
Example1Listcontainingallthevariablesandalltheobservations.
dataa;
inputyearsalescost;
profit=sales-cost;
cards;
19811213211021
19821982312928
19831698214002
19841843214590
;
run;
procprintdata=a;
title'SimplePROCPRINTReport';
run;
Example2RemovalofcolumnOBSandimpressionlimitedtothefirst5observations.
dataexprev;
inputRegion$State$Monthmonyy5.
ExpensesRevenues;
formatmonthmonyy5.;
datalines;
SouthernGAJAN9520008000
SouthernGAFEB9512006000
SouthernFLFEB95850011000
NorthernNYFEB9530004000
NorthernNYMAR9560005000
SouthernFLMAR95980013500
NorthernMAMAR9515001000
;
procprintdata=exprev(obs=5)noobs;
varmonthstateexpenses;
title'MonthlyExpensesforOfficesinEachState';
run;
Example3InstructionIDwithnotsortedobservations
databid;
inputidage;
datalines;
98765
68775
25455
23670
;
procprint;
run;
Example4InstructionID,aftersortingoftheobservations.
databid2;
inputpat_idage;
datalines;
98765
68775
25455
23670
;
procsort;
bypat_id;
run;
procprint;
*varpat_id;
idpat_id;
run;
Example5Testofoneortheothercondition,instructionWHERE
databid3;
inputpat_idage;
datalines;
98765
68775
25455
23670
;
procsort;
bypat_id;
run;
procprintnoobs;
varage;
whereage<75;
run;
Example6InstructionSUM.
datatrim;
inputvendor$moisquantiteCOMMA5.tot_vendorcomma11.2;
datalines;
Hollingsworth0453010,573.50
Hollingsworth051,12022,344.00
Hollingsworth051,03020,548.50
Jones041,11022,144.50
Jones0467513,466.25
Smith041,71534,214.25
Smith0651210,214.40
Smith061,00019,950.00
;
run;
PROCPRINTDATA=trimNOOBS;
TITLE'Totalofvariablesnames';
VARvendormoisquantitetot_vendor;
WHEREquantite>500ORtot_vendor>20000;
SUMquantitetot_vendor;
RUN;
Example7InstructionsSUMandBYstatement
datatrim2;
inputvendor$moisquantiteCOMMA5.tot_vendorcomma11.2;
datalines;
Hollingsworth0453010,573.50
Hollingsworth051,12022,344.00
Hollingsworth051,03020,548.50
Jones041,11022,144.50
Jones0467513,466.25
Smith041,71534,214.25
Smith0651210,214.40
Smith061,00019,950.00
;
run;
procsort;
byvendor;
run;
PROCPRINTDATA=trim2NOOBS;
TITLE'SummarybyVender';
byvendor;
VARvendormoisquantitetot_vendor;
WHEREquantite>500ORtot_vendor>20000;
SUMquantitetot_vendor;
RUN;
Example8InstructionPAGEBYandSUMBY
datatrim3;
inputvendor$moisquantiteCOMMA5.tot_vendorcomma11.2;
datalines;
Hollingsworth0453010,573.50
Hollingsworth051,12022,344.00
Hollingsworth051,03020,548.50
Jones041,11022,144.50
Jones0467513,466.25
Smith041,71534,214.25
Smith0651210,214.40
Smith061,00019,950.00
;
run;
procsort;
byvendor;
run;
PROCPRINTDATA=trim3NOOBS;
TITLE'SummarybyVender';
byvendor;
VARvendormoisquantitetot_vendor;
WHEREquantite>500ORtot_vendor>20000;
SUMquantitetot_vendor;
SUMBYvendor;
PAGEBYvendor;
RUN;
Pagebyoptioncontrolspageejectsthatoccurbeforeapageisfull.
Sumbyoptionlimitsthenumberofsumsthatappearinthereport.
Example9OptionswithLabel,Double,TitleandFootnote
PROCPRINTDATA=trim5NOOBSlabeldouble;
TITLE'SummarybyVendor';
FOOTNOTE'ResultsofData-trim4';
VARvendormoisquantitetot_vendor;
SUMquantitetot_vendor;
LABELvendor='Vendor'
mois='Mois'
quantite='QuantityofVendor'
tot_vendor='TotalofVendors';
RUN;
2.GeneratingfrequencytablesusingPROCFREQprocedure
TheFREQprocedureproducesone-,two-,…n-way(crosstabulation)frequencytables.
TheSASprocedurePROCFREQiscommonlyusedtoproducesummarydataintabularform.Itcanbeusedoneithercharacterornumericdata.Statisticalanalysiswillbefollowedlater.Sevenexamplesareshownhereusingthisprocedureonfreq_xdataset.ThefollowingisasummaryofoptionsandoptionalstatementsthatcanbeusedwithPROCFREQ.Optionalstatementscanbeinanyorder,whileoptionsareenteredattheendoftheTABLESstatement,following"/"andbefore";"NotethatthislistrepresentsonlyaportionofallavailabletotheuserfromSAS:
∙TABLES-optionalstatementforspecifyingthevariablestobeincludedintheanalysis.
∙WEIGHT-optionalstatementforspecifyingthevariablestobesummedforeachvalueofthevariablesspecifiedintheTABLESstatement.
∙MISSING-optiontoincludemissingvaluesinthecalculationswithinthetable.
∙MISSPRINT-optiontodisplaythemissingvaluesinthetableswithoutincludingtheminthecalculations.
∙LIST-optiontolistvaluesofvariablessidebysideratherthanintabularform.
∙OUT=-optiontocreateadatasetcontainingtheoutputgeneratedbytheTABLESstatement.
Therearesomeofoptions,Nofreq,Norow,Nocol,Nopercentetal.
Syntax:
PROCFREQoptions;
BYvariables;
TABLESrequests;
WEIGHTvariable;
Example1:
simpleoutput
datafreq_01;
inputname$sex$ageheight;
datalines;
AllanM25174
BenM23176
ChristineF24164
DavidM32174
EdwardsM36178
Frank.38172
GloryF28166
HillM32170
JackM33172
Katy.26162
LilyF24169
PaulaF.163
;
procfreqdata=freq_01;
title1'PROCFREQ:
example01';
title2'Nokeywordsspecified';
run;
Example2:
One-waytable
procfreqdata=freq_02;
tablessexage;
title'1-waytablesforsexandagespecifiedbyTABLESkeyword';
run;
Example3:
2-waytables
procfreqdata=freq_03;
tablessex*age;
title'two-waytablesforsexandagespecifiedbyTABLESkeyword';
run;
Example4:
2-waytableslistingofthevaluesofthevariablessidebyside
procfreqdata=freq_04;
tablessex*age/listmissing;
title'two-waytablesusinglistandmissing';
run;
Example5:
3waytables
procfreqdata=freq_05;
tablesname*sex*age;
title'3waytable:
heightbyweight,controllingforname';
/*Thefirstvariablerepresentsthecontrolvariable*/;
run;
Example6:
Weightdata
DATAfreq_06;
INPUTrater1rater2count;
DATALINES;
115
122
131
211
227
232
311
322
339
;
PROCFREQDATA=freq_06;
WEIGHTcount;
TABLErater1*rater2;
TITLE1'weighteddata';
RUN;
Example7:
Outoption
procfreqdata=freq_01;
tablesage/out=freq_07;
title'createnewdatasetusingoutoption';
run;
Example8:
Missing/Missprint
procfreqdata=freq_01;
tablessex/missing;/*misprint*/
run;
Example9:
NLEVELS
dataa;
inputagegrpsex$@@;
datalines;
1F1F1M2M2M3F3F3F
;
procfreqdata=anlevels;
tablessex*agegrp/noprint;
run;
ThisoptioninPROCFREQstatementisusedtodisplaythe“NumberofVariableLevels”.ByusingthisoptionswecangetthedistinctcountforeachvariablelistedintheTABLESstatement.ItisbesttouseNLEVELSandNNOPRINToptionsoptiontoknowthenumberoflevelsofvariablebeforeprintingthefrequencytableifthedatasetistoolargeinsizeandifyouunawareofwhatcouldbedistinctcountforeachvariable.
Example10:
CROSSLIST
displayscrosstabulationtablesinODScolumnformat.ThisoptioncreatesatablethathasatabledefinitionthatyoucancustomizebyusingtheTEMPLATEprocedure.
procfreqdata=anlevels;
tablessex*agegrp/crosslist;
run;
Warning:
youcannotspecifyboththeLISToptionandtheCROSSLISToptioninthesameTABLESstatement.
TheCROSSLISToptionlooksthesameasLISToption,buttherearefewdifferencesasshownbelow.
CROSSLISTLIST
StatisticsFREQUENCYFREQUENCY
PERCENTPERCENT
ROWPERCENTCUMULATIVEFREQUENCY
COLUMNPERCENTCUMULATIVEPERCENT
TotalsProducessubtotalsandfinaltotals.Nototals
RowswithDisplaythevariablelevelswithSuppressthevariablelevelswith
zerofrequencieszerofrequencies
zerofreq
3.GeneratingreportusingMEANSprocedure
PROCMEANSonlybeperformedonnumericdata
∙Thisproceduregivesthefollowingsummarystatistics(ifnooptionsarespecified)foreachvariablelistedintheVARstatement:
numberofobservations,mean,standarddeviation,minimumvalue,maximumvalue,andstandarderrorofthemean.
∙Options:
Youcanselectwhichstatisticsyouwanttohaveprintedfromthefollowinglist:
N,NMISS(numberofmissingvalues),MEAN,STD,VAR,MIN,MAX,SKEWNESS,KURTOSIS,lclmanduclmoptionspr
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Generating Reports
![提示](https://static.bdocx.com/images/bang_tan.gif)