由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - Help on understanding how to Creating a Random Sample without Replacement
相关主题
SAS sampling的问题sample size vs. number of regressors
请教SAS random sample的问题Faster Random Sampling with Replacement
[合集] how to randomly draw 10% sample from a data set?SAS random number generatior该怎么用呀?
In sas, how do you randomly pick 10 numbers out of 29?请教一个SAS 数据分配问题
这样还能算Randomized sample吗how to generate 1 to 100k random integer numbers without zeros?
[Teradata] How to randomly select one observation from each group?请教一个sas问题
random sampling in RHelp for beginner of Macro
求高手指教,这个随机过程是Winner Process吗?请教如何用SAS处理这个RANDOM SAMPLING的问题
相关话题的讨论汇总
话题: sampsize话题: sample话题: obsleft话题: pickit话题: random
进入Statistics版参与讨论
1 (共1页)
f*****k
发帖数: 110
1
In the book for SAS adv prep is an example on Creating a Random Sample
without Replacement on P459. Who can help me to understand the logic behind
the method. Or any other better methods? Thanks a lot.
The example and codes are posted below:
Example
You can use a DO WHILE loop to avoid replacement as you create your random
sample. In the following example
# Sasuser.Revenue is the original data set.
# sampsize is the number of observations to read into the sample.
# Work.Rsubset is the data set that contains the random sample that you are
creating.
# obsleft is the number of observations in the original data set that have
not yet been considered for selection.
# totobs is the total number of observations in the original data set.
# pickit is the number of the observation to be read into the sample data
set (if the
RANUNI expression is true), and its starting value is 0.
With each iteration of the DO loop, pickit is incremented by 1. If the
RANUNI
expression is true, the observation that is indicated by the value of pickit
is selected
for the sample, and sampsize is decreased by 1. If the RANUNI expression is
not true,
the observation that is indicated by the value of pickit is not added to the
sample. On
each iteration of the loop, obsleft is decreased by 1 regardless of whether
the
observation is selected for the sample. The process ends when the value of
sampsize is
0 and no additional observations are needed.
data work.rsubset(drop=obsleft sampsize);
sampsize=10;
obsleft=totobs;
do while(sampsize>0);
pickit+1;
if ranuni(0) set sasuser.revenue point=pickit
nobs=totobs;
output;
sampsize=sampsize-1;
end;
obsleft=obsleft-1;
end;
stop;
run;
s*********r
发帖数: 909
2
proc suveyselect
f*****k
发帖数: 110
3
这个PROC好用!谢谢。
SAS adv的方法不是化简为繁么?SAS adv的方法实用吗?

【在 s*********r 的大作中提到】
: proc suveyselect
n******r
发帖数: 1247
4
Ironically the code above is linear time and is much faster than proc
surveyselect implementing the same function on large data sampling.

【在 s*********r 的大作中提到】
: proc suveyselect
n******r
发帖数: 1247
5
this is the fastest sampling without replacement algorithm and it is very
neat too

【在 f*****k 的大作中提到】
: 这个PROC好用!谢谢。
: SAS adv的方法不是化简为繁么?SAS adv的方法实用吗?

1 (共1页)
进入Statistics版参与讨论
相关主题
请教如何用SAS处理这个RANDOM SAMPLING的问题这样还能算Randomized sample吗
问个outlier 和 sample size 的问题哈[Teradata] How to randomly select one observation from each group?
Approximate random samplerandom sampling in R
用SAS sampling的一个问题求高手指教,这个随机过程是Winner Process吗?
SAS sampling的问题sample size vs. number of regressors
请教SAS random sample的问题Faster Random Sampling with Replacement
[合集] how to randomly draw 10% sample from a data set?SAS random number generatior该怎么用呀?
In sas, how do you randomly pick 10 numbers out of 29?请教一个SAS 数据分配问题
相关话题的讨论汇总
话题: sampsize话题: sample话题: obsleft话题: pickit话题: random