资源描述:
《do while or do until.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、SASGlobalForum2007Coders’CornerPaper067-2007DoWhich?Loop,UntilorWhile?AReviewOfDataStepAndMacroAlgorithmsRonaldJ.Fehd,CentersforDiseaseControl,andPrevention,Atlanta,GA,USAABSTRACTThispaperreviewsthethreeloopingcon-Contentsstructs:loop-repeat,dountilanddow
2、hileLoop-RepeatAlgorithm2andoffersexamplesoftheiruse.ThepurposeofthispaperistoprovidebothDoWhich?2pseudo-codeandexamplessothatpro-LoopRepeat.................3DoWhile...................3grammersmayunderstandthedifferenceDoUntil...................3inlogican
3、dmakeanappropriatechoiceDoIterate..................3fortheiralgorithm.ThetwodatastepMacroloops.................4loopprocessingverbs:continue(returntoTestingduringloop4loop-top),andleave(exit)areillustrated.ContinueorLeave..............4Macroexamplesusing%
4、gotoareshownMacro%goto................5forcontinueandleave.TheWhitlocksub-Usinglogicinconditions5settingloop—alsoknownastheDo-Usingbooleanlogic.............5Whitlock(DOW)loop—anddouble-DOWCombiningiterationwithloopcontrol....6areillustrated.Whitlocksubset
5、ting:dountil(last.by-var)..6Double-DOW................7Topicscovered:loop:loop...repeatusinggotoConclusion7dountil(...)Bibliography.................8dowhile(...)testinloop:ifconditionthen...continueifconditionthen...leavemacro%gotodoWhitlock:dountil(last.
6、var)Audience:intermediateusersandmacroprogram-mers.Keywords:dountil,dowhile,Do-Whitlock,doubleDOW,DOW,until(last.by-var),loop,re-peat,subsetting,until,while,Whitlockdo-loop,INTRODUCTIONRSASsoftwareprovidestwoloopcontrolverbs:untilandwhile.Thedifferencebet
7、weenthetwokeywordsisthatwhiletestsitscondi-tionatthetopoftheloopanduntiltestsitsconditionatthebottomontheloop.Thisisnotobviousbecausethesyntaxrequiresbothverbstocomeafterthekeyworddo:dowhile(...)dountil(...).ManyquestionstotheSAS-Llistservearefrombeginnin
8、gprogram-merswhodonotunderstandthedifferencebetweenthesetwoloopcontrolconstructsnorthedifferenceinlogicneededtoimplementthesamealgorithm.Thispaperprovideabasicpseudo-codealgorithmwithcodeexam-plesillustratingtheloop