I want to populate Basic Safety Messages in Vanet, and I am using Omnet++, do I really need sumo and vein or only sumo in achieving this since I only need the data in Matlab for analysis using machine learning
SUMO is dedicated to include flexible mobility models for your simulation. To the best of th knowledge (from ns-3 perspective) you can enable BSM packet simulation without SUMO, assuming ConstantMobilityModel or RandomWalkMobilityModel, if they are useful in your simulation. I believe you will have similar Models in OMNET++.
As Mohammad writes, SUMO is the recommended way to simulate mobility of vehicular nodes, regardless of network simulator. Whether you need a network simulator depends on what you want to investigate; if you only want to analyze traffic behavior through machine learning, you may simply want to use SUMO. If you want to analyze the network, using Veins is one of multiple good options.
Veins is pretty much completely integrated with SUMO, and with good reason: it is the de-facto standard for micro-simulation of traffic. If you want meaningful results that you can also publish, using realistic vehicle behavior is one important criterion. Another important criterion is to use a state of the art network simulator: your choice of OMNeT++/Veins is a good one. The suggestion given by Shafagat, using ns-2, is definitely a bad recommendation, especially for new projects: ns-2 has been out of development for a decade.