资源描述:
《AN INTRODUCTION TO PROC SQL》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、SUGI27Hands-onWorkshopsPaper191-27®ANINTRODUCTIONTOPROCSQLKatieMintenRonk,SteveFirst,DavidBeamSystemsSeminarConsultants,Inc.,Madison,WIQUIT;ABSTRACT7PROCSQLisapowerfulBaseSASProcedurethatcombinesthefunctionalityofDATAandPROCstepsintoasinglestep.ASIMPLEPROCSQLPROCSQLcansor
2、t,summarize,subset,join(merge),andAnasteriskontheSELECTstatementwillselectallcolumnsfromconcatenatedatasets,createnewvariables,andprinttheresultsthedataset.Bydefaultarowwillwrapwhenthereistoomuchorcreateanewtableorviewallinonestep!informationtofitacrossthepage.Columnheadi
3、ngswillbeseparatedfromthedatawithalineandnoobservationnumberPROCSQLcanbeusedtoretrieve,update,andreportonwillappear:informationfromSASdatasetsorotherdatabaseproducts.ThispaperwillconcentrateonSQL'ssyntaxandhowtoaccessPROCSQL;informationfromexistingSASdatasets.Someofthetop
4、icsSELECT*coveredinthisbriefintroductioninclude:FROMUSSALES;QUIT;WriteSQLcodeusingvariousstylesoftheSELECTstatement.(seeoutput#1forresults)DynamicallycreatenewvariablesontheSELECTstatement.UseCASE/WHENclausesforconditionallyprocessingthedata.Joiningdatafromtwoormoredatase
5、ts(likeaMERGE!).LIMITINGINFORMATIONONTHESELECTConcatenatingqueryresultstogether.Tospecifythatonlycertainvariablesshouldappearonthereport,thevariablesarelistedandseparatedontheSELECTstatement.TheSELECTstatementdoesNOTlimitthenumberofvariablesWHYLEARNPROCSQL?read.TheNUMBERo
6、ptionwillprintacolumnonthereportPROCSQLcannotonlyretrieveinformationwithouthavingtolabeled'ROW'whichcontainstheobservationnumber:learnSASsyntax,butitcanoftendothiswithfewerandshorterstatementsthantraditionalSAScode.Additionally,SQLoftenPROCSQLNUMBER;usesfewerresourcesthan
7、conventionalDATAandPROCsteps.SELECTSTATE,SALESFurther,theknowledgelearnedistransferabletootherSQLFROMUSSALES;packages.QUIT;(seeoutput#2forresults)ANEXAMPLEOFPROCSQLSYNTAXEveryPROCSQLquerymusthaveatleastoneSELECTCREATINGNEWVARIABLESstatement.ThepurposeoftheSELECTstatementi
8、stonametheVariablescanbedynamicallycreatedinPROCSQL.columnsthatwillappearonthereportandtheorderi