*** guess you are trying to transform the table from wide to long, here is a way I recently learned, which may be applied to more than 2 M, hope it is right and helpful ;
data new (keep= m grp);
set ttest;
array m_array[2] M1 M2;
do i = 1 to 2;
m = m_array[i];
grp = i ;
output;
end;
drop i ;
run;