由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - [Help] SAS CODE FOR RANDOM SAMPLING
相关主题
请教如何用SAS处理这个RANDOM SAMPLING的问题Approximate random sample
[合集] 两个SAS问题求助 R sample in matrix form
[合集] how to randomly draw 10% sample from a data set?电话面试,对方要求SAS code samples
问个用SAS做Random Sample的问题[合集] 问一个SAS做randomization assignment 的问题
sample distribution的理解线性回归的SAS编程疑问
这样还能算Randomized sample吗请教两个关于SAS的问题
谁做过PROPENSITY SCORE的SIMULATION?SAS base 87% pass today
random sampling in Rweird SAS
相关话题的讨论汇总
话题: a02话题: 1996话题: a01话题: controls话题: sampling
进入Statistics版参与讨论
1 (共1页)
K*******5
发帖数: 98
1
I need help for the SAS code Or if you have any idea. Thank you very much.
2 data sets: cases, controls.
Want to create a new data set, providing a random sample of controls at a
ratio of 5:1 matched for each observation from cases. do not worry about the
number of controls. I have enough controls for each case from my original
data.
Data cases;
Input site$ year$ id$;
Datalines;
A01 1996 c01
A02 1996 c02
A02 2000 c03
A03 1999 c04
……..
;
Data controls;
Input site$ year$ id;
Datalines;
A01 1996 1
A01 1996 2
A01 1996 3
A01 1996 4
A01 1999 5
A02 1996 6
A02 1996 7
A02 1996 8
A02 1996 9
A02 1996 10
A02 1996 11
A02 1996 12
A02 1997 13
A02 1997 14
A02 1997 15
A02 1997 16
A02 1997 17
A02 2000 18
……..
;
t*****w
发帖数: 254
2
Data controls;
Input site$ year$ id;
Datalines;
A01 1996 1
A01 1996 2
A01 1996 3
A01 1996 4
A01 1999 5
A02 1996 6
A02 1996 7
A02 1996 8
A02 1996 9
A02 1996 10
A02 1996 11
A02 1996 12
A02 1997 13
A02 1997 14
A02 1997 15
A02 1997 16
A02 1997 17
A02 2000 18
;
data ratio;
set controls;
x = RAND('BERNOULLI',0.2) ;
if x eq 1 then output;
;
run;
K*******5
发帖数: 98
3
Thank you for your help.
It looks like i did not make my question clear. I need random samples from
CONTROLS. The samples from CONTROLS need to match each observation from
CASES by site and year. The ratio is 5:1. 5 controls to 1 case.

【在 t*****w 的大作中提到】
: Data controls;
: Input site$ year$ id;
: Datalines;
: A01 1996 1
: A01 1996 2
: A01 1996 3
: A01 1996 4
: A01 1999 5
: A02 1996 6
: A02 1996 7

a****g
发帖数: 8131
4
how about that
for each case, do a matched sampling of 5 controls
iterate all cases
clearly this will be an calculation expensive
alternatively, suppose you have 100 cases,
ask for a random sampling of 500 controls with equal weight on the labels
I haven't done any sampling for a lot time thus cannot write a code for you.
just some thoughts to share with you.

the

【在 K*******5 的大作中提到】
: I need help for the SAS code Or if you have any idea. Thank you very much.
: 2 data sets: cases, controls.
: Want to create a new data set, providing a random sample of controls at a
: ratio of 5:1 matched for each observation from cases. do not worry about the
: number of controls. I have enough controls for each case from my original
: data.
: Data cases;
: Input site$ year$ id$;
: Datalines;
: A01 1996 c01

1 (共1页)
进入Statistics版参与讨论
相关主题
weird SASsample distribution的理解
SAS help这样还能算Randomized sample吗
问一个简单的SAS问题,多谢谁做过PROPENSITY SCORE的SIMULATION?
SAS快捷键问题random sampling in R
请教如何用SAS处理这个RANDOM SAMPLING的问题Approximate random sample
[合集] 两个SAS问题求助 R sample in matrix form
[合集] how to randomly draw 10% sample from a data set?电话面试,对方要求SAS code samples
问个用SAS做Random Sample的问题[合集] 问一个SAS做randomization assignment 的问题
相关话题的讨论汇总
话题: a02话题: 1996话题: a01话题: controls话题: sampling