OP: first, determine if this is really an issue with MIDI latency or not. When you record a MIDI track, look at the MIDI notes in the PRV relative to the grid and see if they're all off by a consistent amount. If they're reasonably close and not consistently out of time, then it's
not MIDI latency that's the problem.
[I find that when I use hardware synths, recording MIDI first and then recording audio, the audio may lag the MIDI notes slightly (but software synthesizers are always right on the money). I can easily mitigate that by manually inserting a MIDI note that's quantized to the grid and sliding the resulting audio over to exactly match up to it. At that point, I can be confident that any timing errors are the result of my own sloppy playing.]
But the problems described by both sharke and the OP are more likely monitoring problems caused by audio - not MIDI - latency. Audio latency has two primary factors: buffer size and the internal latency of individual plugins. (Plugin Delay Compensation (PDC) is not the culprit; it's job is to slow down the fast plugins so that the laggards can keep up.)
For ASIO and WDM, there is a predictable relationship between buffer size (including the hidden safety buffer mentioned by bvideo) and latency: it's going to be buffer size divided by the sample rate (latency can be reduced by reducing the buffer size or by . Therefore, if you still have unacceptable lag even at small buffer sizes, plugin latency is the more likely culprit.
Often, you cannot do anything about a plugin's internal latency. However, as noted above, you can temporarily disable PDC and tell SONAR to ignore plugin latency. This is the quickest way to determine if your latency is mainly due to plugin latency or to audio buffer size.
Note that bypassing a plugin or muting a track does not affect PDC, which is still going to be calculated and compensated for as if the plugin were still active. The only way to to figure out which particular one's causing the greatest delay is to completely remove them one by one.
Plugins that cause the greatest latency are going to be the ones that have large internal buffers, such as equalizers (especially linear-phase such as the LP-64) and reverbs (especially convolution types such as PerfectSpace). It's good practice to leave such plugins completely out of the chain until you've finished tracking.
But if you need a plugin to be active while tracking, it may be enough to turn of PDC. Sometimes the subsequent lack of synchronization between tracks won't be too much of a distraction.
But if the lack of track synchronization causes problems, you can look at individual plugins, some of which have adjustable internal buffers. PerfectSpace, for example, has a buffer size setting (click on the Info button, then the "set latency" button and choose a smaller buffer - put it back to a larger one after you're done tracking). EQs often have buffer adjustments too. If you use Ozone, you can reduce the latency of its equalizer via the EQ Options dialog. If you use FabFilter Pro-Q, you can choose the "zero latency" (minimum phase) option. AFAIK, SONAR's bundled EQs do not offer this feature, although I can't speak to ProChannel as I am not a user.