You must know the formula, i.e. atomic composition of magnesium oxide, and then it would be easy to convert the atomic composition into weight composition, through simple reasoning, given the atomic masses of the in it.
Magnesium oxide has formula MgO (that is, ##Mg_1O_1##).
This means that in every sample of this substance there is the same number of Oxygen and Magnesium atoms.
From we see that the atomic masses are 24.3 (Mg) and 16.0 (O). Magnesium atoms are heavier than oxygen atoms, so we expect more than 50% of magnesium in the weight composition.
Taking just one atom of Mg and one atom of O you will get a mass of 16.0 + 24.3 = 40.3 for the unit that represents the minimum amount of magnesium oxide.
There is a 16.0/40.3 • 100 = 39.7% in mass of oxygen, and
24.3/40.3 • 100 = 60.3% in mass of magnesium in it.
These percentages are the same if you take 1000 or one billion of couples ##MgO## in any amount of this substance.
Hope this will help.
Here is a video which discusses how to calculate percent composition for a iron oxide compound using experimental data.
This video is of an experiment which gives data you can use to calculate the percent composition of MgO.