The self-organizing map (SOM) neural network, also called Kohonen neural network, is an effective tool for analysis of multidimensional data. This network can be used for cluster analysis while preserving data structure (topology) in such a way that similar inputs (data) remain close together in the output layer of the network. However, no algorithm that can automatically cluster discrete groups of data is presented, and our simulation results show that the classic SOM algorithm cannot cluster discrete data correctly. In this paper, we present a novel SOM-based algorithm that can automatically cluster discrete groups of data using an unsupervised method. This method consists of three phases: at the first phase, an algorithm called "second winner" is performed, in which neurons in the competitive layer of the network find their initial location in the network space. At the second phase, a method called "batch learning" is employed, and at the end of this phase, training of the SOM network is finished. And finally at the third phase, data clustering is completed by removing the wrong links between neurons. Three real world data sets and an example of synthetic data are utilized to illustrate the accurateness and effectiveness of the proposed approach. (C) 2011 Elsevier B.V. All rights reserved.