ソートせずにbyステートメントを使用する byステートメントに notsorted オプションを付与する。 data A1; set Q1; retain GROUP 0; by val notsorted; if first.val then GROUP + 1; run;