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 t... 阅读全帖 |
|
D*D 发帖数: 236 | 2 for large dataset and exact number of samples the following is an example
from the SAS advanced certificate guide of the fastest algorithm to serve
that purpose
much faster than proc surveyselct
data work.rsubset(drop=obsleft sampsize);
sampsize=100;
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... 阅读全帖 |
|
a*z 发帖数: 294 | 3 在adv pre 中读到:
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;
教材说是random sample without replacement.我怎么觉得只是读了dataset中的前10
个sample?因为picki... 阅读全帖 |
|
D******n 发帖数: 2836 | 4 %let startobs=1;
%let step=4;
data a2;
do pickit=&startobs to totalobs by &step;
set a1 point=pickit nobs=totalobs;
output;
end;
stop;
run; |
|
c*****s 发帖数: 180 | 5 Creating a Systematic Sample from an Unknown Number of Observations (
continued)
Example
In the last example, you saw a DATA step that selects a systematic sample of
the Sasuser.Revenue data set by reading every tenth observation beginning
with observation number 1, without prior knowledge of the total number of
observations in Sasuser.Revenue. Remember that totobs is assigned a value
that is the total number of observations in Sasuser.Revenue. The variable
pickit has an initial value of 1 |
|
c*****s 发帖数: 180 | 6 Now that you have seen how to use the CEIL function in conjunction with the
RANUNI function, let's take a look at how to use these functions in a DATA
step to create a random sample. You use the CEIL and RANUNI functions
together to generate a random integer that is assigned as a value for the
variable to which the POINT= option points.
Example
In the following example, the CEIL and RANUNI functions are used together in
the assignment statement for pickit, which is the variable that is pointed
t |
|