资源描述:
《Combining PROC SQL Summary Functions with Logical Expressions》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、CombiningPROCSQLSummaryFunctionswithLogicalExpressionsGlennWright,M.P.A.,KaiserPermanente,Oakland,CAABSTRACTInSAS,atrueexpressionsuchas“2+2=4”or“3>=0”resolvestothenumericvalue1,andafalseexpressionsuchas“2+2=5”resolvestothenumericvalue0.SuchexpressionscanbeusedasinputforPROCSQL
2、summaryfunctionsinordertocreatecustomizedsummaryvariablesthatdrawuponmultiplerecords.Forexample,onecouldusethistechniqueonadatabaseofhealthcareclaimlinesinordertocreateclientsummaryrecordsshowingwhichclientsreceivedacertaincombinationofservicesonatleastonedayduringacertaintime
3、period.OnecanalsocombinethesetechniqueswithPROCSQLJOINstocreatesummaryvariablesthatcombinedatafrommultiplesources.INTRODUCTIONAnalystsoftenproducereportsthatsummarizedatabykeyvalues.SASprovidesseveraltoolsforthispurpose,suchasPROCFREQ,PROCMEANSwithaBYstatement,andtheGROUPBYsta
4、tementinPROCSQL.Thesetoolscaneasilyprovidesimplesummarystatisticssuchascounts,means,andmaximums.However,manyprogrammersdonotrealizethatthesetechniques–PROCSQLinparticular–canproducemorecomplexsummarystatisticsaswell:“Whatpercentageofclientsreceivedatleastonepregnancytestduring
5、thecalendaryear?”,or“Whichclinicsprovidedantibioticstoallclientswithacertaindiseasewithinsevendaysofdiagnosis?ThispapershowshowtocombinethreesimpleSASconceptsintoapowerfulreportingtechniquethatcanreplacemanypagesofDATAstepsandMEANS,FREQ,andSORTprocedureswithafewPROCSQLsteps.Ma
6、nyprogrammersfindthetechniqueconfusingwhentheyfirstencounterit,soIwillexplainitpiece-by-piece.Eachelementofthetechniqueisusefulindividually,butcombinedtheyaremuchmorethanthesumoftheirparts.FLAGVARIABLESThefirstconcepthelpfulforunderstandingthetechniqueisflagvariables.Aflagvari
7、ableissimplyanumericvariablethattakesoneofonlytwovalues,1(TRUE)or0(FALSE).Forexample,inadatasetwhereeachrecordrepresentsasingleday,theflagvariableRAINYcouldindicatethattheweatheronthatdaywaseitherrainy(TRUE,or1)orsunny(FALSE,or0).Ofcourse,youcouldstorethatinformationinacharact
8、ervariable,withvalueslike“Rainy”and“Sunny”,orsimply“Y”and“N”,