呵呵,复杂了一点。class =1 前1/3 ;class =2 中间1/3;class=3后1/3。
data raw;
input id$ price;
cards;
shirt1 10
shirt2 34
shirt3 8
shirt4 50
shirt5 50
;
run;
data _null_;
set raw end=end;
if end then call symput('n',_n_);
run;
data result;
set raw;
if _n_<=&n/3 then class=1;
else if _n_<=2*(&n/3) then class=2;
else class=3;
run;