There are many dog owners who need their dogs to stay in the yard while they are gone. If you want your dog to stay in the yard you have two different options:
1- Build a traditional fence from wood, vinyl, or chainlink. The drawback with these is that they are often unsightly, expensive, and time consuming to build.
2- Install an electric dog fence. Much more affordable.
An electronic dog fence works by installing a wire around the perimeter of your yard. Your dog wears a special collar that is synced with the fence wire. When the dog approaches a pre-determined distance from the fence wire a tone is emitted. If the dog continues approaching the the fence he receives an electric correction or shock.
It is important to note, however, that you can't just install an electric dog fence and expect the dog to stay in the yard. You will have to train your dog with the fence equipment what it means to stay in the yard.

