s*********h 发帖数: 6288 | 1 I want to select randomly one observation from each group_id.
If it can be done in subqueries, it's even better.
Thanks. |
c****0 发帖数: 14490 | 2 是指一组数按group_id可以分为几个小组,然后你要在每个小组中randomly选一个obs
吗?
如果是,
说下想法,顺便等高手指正
1.用stata
sample 1,by group_id
2.用sas
PROC SURVEYSELECT DATA=temp;
STRATA variables; *这里的STRATA 变量要先sort过
3.如果取一些数,也可以考虑create new random variable,一般我用 random=ranuni
(n);然后sort random或者设条件取sample
【在 s*********h 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I want to select randomly one observation from each group_id. : If it can be done in subqueries, it's even better. : Thanks.
|
s*********h 发帖数: 6288 | 3 多谢回帖。
但是我想在teradata里面完成,不借用其他统计软件。
obs
ranuni
【在 c****0 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 是指一组数按group_id可以分为几个小组,然后你要在每个小组中randomly选一个obs : 吗? : 如果是, : 说下想法,顺便等高手指正 : 1.用stata : sample 1,by group_id : 2.用sas : PROC SURVEYSELECT DATA=temp; : STRATA variables; *这里的STRATA 变量要先sort过 : 3.如果取一些数,也可以考虑create new random variable,一般我用 random=ranuni
|
b*********n 发帖数: 2975 | 4 use sample 1 after your code
or generate random number function and order it and top 1 like SAS did
I want to select randomly one observation from each group_id.
If it can be done in subqueries, it's even better.
Thanks.
【在 s*********h 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I want to select randomly one observation from each group_id. : If it can be done in subqueries, it's even better. : Thanks.
|
c****0 发帖数: 14490 | 5 哦,没看清teredata,咳咳~那个木有用过,╮(╯﹏╰)╭
加油!
【在 s*********h 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 多谢回帖。 : 但是我想在teradata里面完成,不借用其他统计软件。 : : obs : ranuni
|
s*********h 发帖数: 6288 | 6 this is a good way. Thanks.
BTW, is it efficient? I was hoping there is a generic way of doing it.
【在 b*********n 的大作中提到】![](/moin_static193/solenoid/img/up.png) : use sample 1 after your code : or generate random number function and order it and top 1 like SAS did : : I want to select randomly one observation from each group_id. : If it can be done in subqueries, it's even better. : Thanks.
|
b*********n 发帖数: 2975 | 7 sample 1 is from teradata itself, should very efficient,
however, if you want to have a very good random generator, you may try some
numerical libary by Fortran/C++ and then
insert the generated random value into your table, then top 1
it also not a big deal for teradata
this is a good way. Thanks.
BTW, is it efficient? I was hoping there is a generic way of doing it.
【在 s*********h 的大作中提到】![](/moin_static193/solenoid/img/up.png) : this is a good way. Thanks. : BTW, is it efficient? I was hoping there is a generic way of doing it.
|