楼主: 虞子期
3021 11

筛选观测值 [推广有奖]

  • 16关注
  • 0粉丝

本科生

86%

还不是VIP/贵宾

-

威望
0
论坛币
25 个
通用积分
0
学术水平
2 点
热心指数
2 点
信用等级
3 点
经验
1770 点
帖子
58
精华
0
在线时间
102 小时
注册时间
2012-8-31
最后登录
2015-1-19

楼主
虞子期 发表于 2013-5-31 09:56:41 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
a        b        c
173.2465        5.641        28375
173.2908        5.645        7161
173.1294        5.642        767098
197.2151        9.998        51203
197.2644        9.999        13350
197.0907        9.999        1193382
197.3505        10.001        6035
173.8311        6.39        6832
197.899        10.34        7456


上述数据中,任意两行观测的变量a和b相减,若-0.5=<变量a的差值=<0.5, -0.3=<变量b的差值=<0.3,则将这些观测输出。
谢谢各位了!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:筛选观测 观测值 51203

本帖被以下文库推荐

沙发
playmore 发表于 2013-5-31 10:03:53
任意两行需要全连接下,即
proc sql noprint;
select a.*,b.a as a_b,b.b as b_b,b.c as c_b
from table as a,table as b;
quit;

然后用data步算下a和a_b,b和b_b,c和c_b的差值,再筛选就好了

我这是麻烦的办法,可能还有好办法,等楼下的吧

playmore邀请您访问ChinaTeX论坛!!!进入ChinaTeX论坛

藤椅
playmore 发表于 2013-5-31 10:03:57
任意两行需要全连接下,即
proc sql noprint;
select a.*,b.a as a_b,b.b as b_b,b.c as c_b
from table as a,table as b;
quit;

然后用data步算下a和a_b,b和b_b,c和c_b的差值,再筛选就好了

我这是麻烦的办法,可能还有好办法,等楼下的吧

playmore邀请您访问ChinaTeX论坛!!!进入ChinaTeX论坛

板凳
jingju11 发表于 2013-5-31 10:05:25
PROC SQL;
SELECT _1.* FROM HAVE AS _1, HAVE AS _2 WHERE _1.A-_2.A BETWEEN -.5 AND .5 OR/AND _1.B-_2.B BETWEEN -.3 AND .3;

报纸
playmore 发表于 2013-5-31 10:12:24
jingju11 发表于 2013-5-31 10:05
PROC SQL;
SELECT _1.* FROM HAVE AS _1, HAVE AS _2 WHERE _1.A-_2.A BETWEEN -.5 AND .5 OR/AND _1.B-_2 ...
嗯,这个看起来简单多了
但还是要靠全连接吧
表大的话还是比较费时间的
playmore邀请您访问ChinaTeX论坛!!!进入ChinaTeX论坛

地板
虞子期 发表于 2013-5-31 10:27:13
谢谢!我的表确实很大,有什么更精简的方法吗?

7
jingju11 发表于 2013-5-31 10:54:21
费时间在这里应该不是最大的问题。因为这种程序通常不需要反复执行。问题是是否有足够的内存。从内存使用的方面来看,SQL在SAS里是最好的选择之一。我的观察是SQL在数据变大时,所占内存相对较为稳定,而其他的过程则不然。个人观点。京剧
我对SQL和FREQ的运算效率有个比对。
http://blog.sina.com.cn/s/blog_a3a926360101d69b.html

8
yongyitian 发表于 2013-5-31 11:06:24
/* try this */

data aaa;
input a  b  c;
datalines;
173.2465  5.641 28375
173.2908  5.645 7161
173.1294  5.642 767098
197.2151  9.998 51203
197.2644  9.999 13350
197.0907  9.999 1193382
197.3505 10.001 6035
173.8311  6.39  6832
197.899  10.34  7456
;run;

proc sql;
   select count(*) into :Nobs    from aaa;
   select a into :a separated by ' ' from aaa;
   select b into :b separated by ' ' from aaa;
quit;

data bbb;
   array aa{&nobs} _temporary_ (&a);
   array bb{&nobs} _temporary_ (&b);
   set aaa end=last;
     do i = 1 to &Nobs;
        a1 = aa(i);
        b1 = bb(i);
      if  -0.5 <= a-a1 <= 0.5 or
          -0.3 <= b-b1 <= 0.3 then output;
     end;
run;
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
boe + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

9
虞子期 发表于 2013-5-31 15:43:32
谢谢楼上的大侠但是我运行不了,我的QQ2393695206,能否加你?

10
邓贵大 发表于 2013-5-31 21:55:42
if either column A or B has a big deviation, then grouping the observations by their distance to the origin before selecting will have a clear advantage over Cartesian product. For example,
  1. data hell;
  2.         do n=1 to 1000000;
  3.                 a = 1000*rannor(12345);
  4.                 b = 10*rannor(12345);
  5.                 c = rannor(12345);
  6.                 zone = floor(sqrt(a*a+b*b)/.6);*sqrt(0.5^2+0.3^2)<0.6;
  7.                 output;
  8.         end;
  9.         
  10. proc freq data=hell;
  11.         tables zone/nocum nopct;
  12. run;


  13. proc sql;
  14. *create table pairs as
  15.         select A.n as n_a, B.n as n_b, A.a as a_a, B.a as a_b, A.b as b_a, B.b as b_b, A.c as c_a, B.c as c_b
  16.                 from hell a, hell b
  17.                 where abs(A.a-B.a)<=0.5 and abs(A.b-B.b)<=0.3 and a.n < b.n;
  18. quit;
  19. proc sql;
  20. create table pairs1 as
  21.         select A.n as n_a, B.n as n_b, A.a as a_a, B.a as a_b, A.b as b_a, B.b as b_b, A.c as c_a, B.c as c_b
  22.                 from hell A join hell B on A.zone=B.zone
  23.                 where abs(A.a-B.a)<=0.5 and abs(A.b-B.b)<=0.3 and a.n < b.n
  24.         outer union corr
  25.         select A.n as n_a, B.n as n_b, A.a as a_a, B.a as a_b, A.b as b_a, B.b as b_b, A.c as c_a, B.c as c_b
  26.                 from hell A join hell B on A.zone+1=B.zone
  27.                 where abs(A.a-B.a)<=0.5 and abs(A.b-B.b)<=0.3;
  28. quit;
复制代码
However if you data looks like the following, then I have to say that may the Lord bless you!
  1. data hell;
  2.         do n=1 to 1000000;
  3.                 a = rannor(12345);
  4.                 b = ranuni(12345);
  5.                 c = rannor(12345);
  6.                 zone = floor(sqrt(a*a+b*b)/.6);*sqrt(0.5^2+0.3^2)<0.6;
  7.                 output;
  8.         end;
复制代码
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
Imasasor + 100 + 100 + 3 + 3 + 3 精彩帖子

总评分: 经验 + 100  论坛币 + 100  学术水平 + 3  热心指数 + 3  信用等级 + 3   查看全部评分

Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-1 16:36