下面这段code是为了随机取一些data comp的记录:
data comp;
input x1 x2 x3 f;
cards;
1 1 1 4
1 2 1 5
2 1 1 3
2 2 1 2
1 1 2 1
1 2 2 8
2 1 2 7
2 2 2 6
;
run;
data one;
set comp;
if _n_=rantbl(1230,0.2,0.3,0.5);
run;
data three;
set comp;
if _n_=3;
run;
data two;
a=rantbl(1230,0.2,0.3,0.5);
run;
proc print data=comp;
run;
proc print data=one;
run;
proc print data=two;
run;
proc print data=three;
run;
data one和data three的结果在输出中看到的是不同的:
data one: Obs x1 x2 x3 f
1 1 2 1 5
2 2 1 1 3
data three: Obs x1 x2 x3 f
1 2 1 1 3
为什么会有这种问题呢?是不是和_n_的某些原理相关呢?