How does magic differ from religion? Does this have any impact on the ability of sociologists to study cultures which practice magic?
To answer the first part of this question first, the ability of sociologists to study magic and religion does not depend on the relationship between the two phenomena. A sociologist can study the impact of any form of social practice, given access to cultures that currently engage in that practice. The difficulty comes in whether one needs clear definitions of the two practices before studying them.
One issue is that the term magic is used in two separate senses, one as a way of describing a certain type of relationship with supernatural powers and one is a sense that is faintly derogatory, often suggesting something illicit or duplicitous. For example, in ancient Rome many religions were legal and widely practiced and magic illegal, although the cult practices themselves were sometimes quite similar.
One neutral way to distinguish between the two is to say that the magician compels supernatural or divine powers while the religious worshiper entreats them, but in fact that distinction is not always true. There are also many practices such as theurgy (as practiced among ancient neoplatonists) which straddle the divide between magic and religion.
Another common distinction is that the term magic is used for cases where the practitioners wish to cause harm such as is the case with curse tablets. However, praying for victory in a war or an athletic contest (which involves harming ones opponents) or even destruction of enemies is often a feature of religion, and thus the distinction doesn't really hold.
Overall, both magic and religion involve some sort of belief in supernatural powers and various forms of ritual or worship; often the main difference between the two is that the term religion is often used positively and magic negatively.