资源描述:
《04-sorting-printing-and-summarizing-your-data》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、The Little SAS Book: A Primer, Fifth EditionChapter4:Sorting,Printing,andSummarizingYourData"Onceinawhilethesimplethingsworkrightoff."PhilGallagherFromtheSAS-LListserv,1994.Reprintedbypermissionoftheauthor.4.1UsingSASProceduresUsingaprocedure,orPROC,islikefillingoutaform.Someoneelsedesign
2、edtheform,andallyouhavetodoisfillintheblanksandchoosefromalistofoptions.EachPROChasitsownuniqueformwithitsownlistofoptions.Butwhileeachprocedureisunique,therearesimilaritiestoo.Thissectiondiscussessomeofthosesimilarities.Allprocedureshaverequiredstatements,andmosthaveoptionalstatements.PR
3、OCPRINT,forexample,requiresonlytwowords:PROCPRINT;However,byaddingoptionalstatementsyoucouldmakethisprocedureadozenlinesorevenlonger.PROCStatementAllproceduresstartwiththekeywordPROCfollowedbythenameoftheprocedure,suchasPRINTorCONTENTS.Options,ifthereareany,followtheprocedurename.TheDATA=
4、optiontellsSASwhichdatasettouseasinputforthatprocedure.Inthiscase,SASwilluseatemporarySASdatasetnamedBANANA:PROCCONTENTSDATA=banana;TheDATA=optionis,ofcourse,optional.Ifyouskipit,thenSASwillusethemostrecentlycreateddataset,whichisnotnecessarilythesameasthemostrecentlyused.Sometimesitiseas
5、iertospecifythedatasetyouwantthantofigureoutwhichdatasetSASwillusebydefault.TouseapermanentSASdataset,issueaLIBNAMEstatementtosetupalibrefpointingtothelocationofyourdataset,andputthedataset'stwo-levelnameintheDATA=option,asdiscussedinsection2.19,LIBNAMEtropical'c:MySASLib';PROCCONTENTSDA
6、TA=tropical.banana;orrefertoitdirectlybyplacingyouroperatingenvironment'snameforthepermanentSASdatasetbetweenquotationmarks,asdiscussedinsection2.20.PROCCONTENTSDATA='c:MySASLibbanana';BYStatementTheBYstatementisrequiredforonlyoneprocedure,PROCSORT.InPROCSORTtheBYstatementtellsSAShowtoa
7、rrangetheobservations.Inallotherprocedures,theBYstatementisoptional,andtellsSAStoperformaseparateanalysisforeachcombinationofvaluesoftheBYvariablesratherthantreatingallobservationsasonegroup.Forexample,thisstatementtellsSAStorunaseparateanalysisforeachstate:Page2/40