Hi "Bhpinder", basically you are doing the right thing, but yes, it can be improved. to exit a do loop use the LEAVE statement (i.e. you can drop GOTO and its target label) use 'do i=1 to dim(check);' thus bypassing hard coding the number of elements in the array further possibilities for improvement: loop exit can also be controlled on the DO statement itself, so look up DO UNTIL and DO WHILE respectively some people prefer using automatic variables (e.g. _n_) for the loop counter because _n_ is automatically dropped i.e. not written to the eventual dataset modifying _n_ does not interfere with the way _n_ gets assigned by the datastep's internal mechanisms so it can be used rather freely (Don't waste too much time thinking about this statement if its meaning is not immediately understandable. I'm sure it can be expressed much better but I'm getting to my limits here with regards to my command of the english language.) (PS: I'm not an advocate of this use of _n_ as it might confuse people for whom SAS is but one of the many tools they use.) Generally I strongly advice to bookmark SAS online documentation. My favourite (not having had access to any SAS system above 9.1.3) being - you guess it - the 9.1.3 Documentation and there especially the Language Reference Dictionary book. SAS has such a rich set of functions, formats, informats, options and statements that skimming through its pages is time well invested. Furthermore there are overview pages in this document such as Functions and CALL Routines : Functions and CALL Routines by Category that I always turn to when a voice inside me says "there must be some function, format, whatsoever that exactly does this". Kind regards Robert
... View more