楼主: rockfido
5124 28

[程序分享] HOW TO DEAL WITH THIS ONE (SURVEYSELECT) [推广有奖]

21
rockfido 在职认证  发表于 2010-3-2 23:09:58
btw, in case it helps other, i guess we could also sorted the data set by r and then choose those obs with _n_ is less then half of the data set size.

22
zjveronique 发表于 2010-3-3 00:23:43
学习了·········

23
soporaeternus 发表于 2010-3-3 09:13:59
21# rockfido
这样可能用到更多的数据步或是过程步,SAS输入输出效率很差的,最好尽量减少搬运工的次数......
Let them be hard, but never unjust

24
rockfido 在职认证  发表于 2010-3-3 10:29:20
thanks a lot. the reason why i changed to that way is because i cant fully follow ur way....lol.....too difficult for me to understand.....but thank you so much !!

23# soporaeternus

25
rockfido 在职认证  发表于 2010-3-3 10:32:24
btw, i really have no clue how r <= %sysevalf(&rto) works.....

as for my data sets, i used rto=0.5 since i need only half of the data set. and it works for one data set, which originally has 40 obs, while it doesnt work for the 2nd data set, which originally has 36 obs (8 groups within each group, there are *_A, *_B, *_C, *_D four obs)-----and it sampled only 12 obs for me......

23# soporaeternus

26
soporaeternus 发表于 2010-3-4 11:28:32
17楼的代码可以解决,某种意义上来说按你的需求用r <= %sysevalf(&rto)来随机抽取是"错误"的......
抽取数量本身应该是正态分布的......
Let them be hard, but never unjust

27
rockfido 在职认证  发表于 2010-3-4 12:37:29
got it. thank you so much!!

26# soporaeternus

28
jingju11 发表于 2010-3-4 13:10:47
soporaeternus 发表于 2010-3-4 11:28
17楼的代码可以解决,某种意义上来说按你的需求用r <= %sysevalf(&rto)来随机抽取是"错误"的......
抽取数量本身应该是正态分布的......
为什么抽取数量是正态分布的?不是常数50吗?

29
soporaeternus 发表于 2010-3-4 13:28:22
28# jingju11
可能是我没表达清楚。
在我老的代码里面,用r<=0.5 (如果0.5是抽取比例的话)来抽取数据,抽出的数据条数应该是正态分布的。而不是严格为totobs*0.5,后来用无放回的原理来抽可以解决这个问题。

条数正态分布可以用以下代码检验
  1. data t;
  2. do i=1 to 100000 by 1;
  3. k=0;
  4. do j=1 to 1000 by 1;
  5. r=ranuni(123456);
  6. if r<=0.5 then k+1;
  7. end;
  8. output;
  9. end;
  10. run;
  11. proc freq data=t;
  12. table k /out=t1;
  13. run;
  14. quit;

  15. proc gplot data=t1;
  16. plot PERCENT*k;
  17. run;
  18. quit;
复制代码

没表达清楚.....嗨...
Let them be hard, but never unjust

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-31 15:59