I would appreciate if anyone explian me about Automatic loop in a datastep and factors that cause the automatic loop to terminate or to fail to terminate?
For looping of the data step (better called cycle of execution or iteration), there is a whole chapter in Base SAS Certification Preparation Guide (Chapter 6, I guess). I would recommend you to read it if you have access to that. It clearly explains the whole process in a lucid way with diagrams.
There is also a doc on that topic with more information--