How Xbee Coordinator search for Channel and set PAN ID that every End node have to choose.

I want to know the steps of how to achieve these process :-

When a coordinator attempts to establish a ZigBee network, it does an energy scan to find the best RF channel for its new network. When a channel has been chosen, the coordinator assigns the logical network identifier, also known as the PAN ID, which will be applied to all devices that join the network.

These steps are handled automatically internal to the XBee dependant on various AT configuration registers (ID, SC, EE, NK, KY, etc). You can find documentation on these registers and in the manual for your XBee.