I am new to the world of Stata and know very less about its features. I need help to rearrange my dataset so that I can analyze my data properly. The arrangement of my dataset is as follows:
Student ID Subject Name 1 Subject Marks 1 Subject Name 2 Subject Marks 2 Subject Name 3 Subject Marks 3 Subject Name 4 Subject Marks 4
1 Math 90 Geography 75 Physics 65 Arabic Language 90
2 Biology 78 Chemistry 70 Geography 90 English 85
3 Arabic 88 Persian 75 English 65 Math 78
4 Biology 75 Physics 100 Chemistry 90 Math 100
You can see currently data has been arranged in a way that the marks of each subject are written adjacent to the subject name against each student i.e. name of a subject is written in one column and obtained marks in that subject is written in next column. Secondly, there is no order in the subject listing (any subject can come at any place against different students). Thirdly it is also not necessary that every student id have the same subjects.

I personally think (you may also suggest other solutions) that in order to analyze this dataset, it is important to rearrange them and subject names should be made variable names and obtained marks should be listed against respective subjects for each student. For this, I can create new variables for each subject name.

I want to know that after creating new variables, how can I traverse each row (each student record) and find the marks of subject 1 and then copy those marks under subject_1 (new variable) and subject 2 marks under subject_2 (new variable) and so on for all subjects.

I will be thankful if someone can guide me.
Thank you