I use four or five MIDI to USB devices at the same time without problems for a total of up to a dozen available MIDI ports in Sonar. They show as in and out ports in the MIDI section of preferences as available ports and ticking them activates them. The ports are then available as MIDI track inputs and outputs.
I can route MIDI between them and yes, Sonar generated MIDI gets sent to them as well.
The "device out of range for system" is a Windows error message, not a Sonar one. Possible causes are a driver not loading properly or exceeding the built-in limit on the number of MIDI devices in some versions of Windows.
You might try this. Windows is notorious for not noticing that the MIDI device now in USB socket 2 is the one that was in socket 1 last time and 3 the time before that. So it creates fresh MIDI devices for each and these rapidly build up if MIDI gear is swapped around between USB sockets. Open Windows control panel and go into device manager.
On the view menu is an entry that lets you also see 'ghost' devices (for which Windows has a device entry but thinks aren't currently connected). If any of them are to do with MIDI right click on the ghost and delete it. Reboot and try connecting your MIDI gear again (before loading Sonar).