Summarize this article:

These usually look like small pink circles and may appear slightly raised around the edges. The anus is just under the tail, and the urogenital opening, the location of the urinary and genital organs, is above the anus toward the center of the abdomen. Sex differences are more difficult to spot in very young pups, but it is possible to sex a pup by looking at the distance between its anus and its urogenital opening. In females, the openings are very close together. You may actually have trouble telling them apart so that the urogenital opening, which in this case is the vulva, and the anus almost seem to be a single opening or structure. In males, the openings are farther apart, so there is very clear separation between the anus and the urogenital opening. You may also see small swellings in the groin area if you have a male. These are the growing testicles. If you can only find one opening, especially if it seems rather large, you should suspect you are dealing with a female, but recheck the animal often or consult an experienced exotics veterinarian just in case you missed the second opening. This opening can be subtle in a very young male, especially if the animal you are working with is a tiny dwarf hamster. The most common pet hamsters, Syrian hamsters, are solitary and need to be kept in individual cages, so early sexing is not very important. Dwarf hamsters, on the other hand, are kept in single-sex groups. If you have pups in a single-sex group, you need to recheck them often until sex is obvious. This will help you avoid accidental pregnancies in your group.
Locate the two openings on the underside of the hamster. Assess the distance between the anus and the urogenital opening. Recheck the hamster at another time if you are still not sure.