楼主: 小鳄鱼a
1176 1

一些问题 [推广有奖]

  • 6关注
  • 10粉丝

学科带头人

3%

还不是VIP/贵宾

-

威望
0
论坛币
125 个
通用积分
0.0040
学术水平
40 点
热心指数
45 点
信用等级
43 点
经验
32801 点
帖子
1185
精华
0
在线时间
1539 小时
注册时间
2009-7-16
最后登录
2018-10-5

50论坛币

跟   https://bbs.pinggu.org/thread-3704218-1-1.html   类似

数据两两合并后,但是新生成一个变量就可以了,这个变量的要求是,两个不同的id,针对其重合的x,求出y比较小的那个赋值给新生成的变量 比如id 1 和2 。重合的为x 123  此时  合并后  x对应的新变量取值为y比较小的。比如 x为1,在id 12 中,分别对应y是0.1 和0.5  那么新生成变量赋值为 0.1 其他类似。x没有重合的新生成变量为0


最后也是要生成一个纵向数据集





idxy

1

2

0.8

1

1

0.1

1

3

0.1

2

2

0.2

2

1

0.5

2

4

0.1

2

3

0.2

3

2

0.2

3

5

0.3

3

1

0.4

3

3

0.1

4

2

0.2

4

1

0.1

4

3

0.1

4

4

0.5

4

6

0.1


最佳答案

jl60156 查看完整内容

data test1; set have(rename=(x=x_ id=id_ y=y_)); do i=1 to nobs; set have point=i nobs=nobs; if id_ ne id then do; if x = x_ then do; newid=cats(put(min(id_,id),best.),',',put(max(id_,id),best.)); _y=min(y_,y); flg=1; output; end; else ...
关键词:pinggu thread 生成变量 HTTP Ping
沙发
jl60156 发表于 2015-5-9 20:18:45 |只看作者 |坛友微信交流群
data test1;
     set have(rename=(x=x_ id=id_ y=y_));
     do i=1 to nobs;
           set have point=i nobs=nobs;
          if id_ ne id then do;
                if x = x_ then do;
                     newid=cats(put(min(id_,id),best.),',',put(max(id_,id),best.));
                                                                                 _y=min(y_,y);
                     flg=1;
                     output;
                end;
                else if x ne x_ then do;
                     newid=cats(put(min(id_,id),best.),',',put(max(id_,id),best.));
                                                                                 _y=0;
                     flg=2;
                output;
                end;
           end;
     end;
run;
proc sort data=test1 out=test2(keep=newid x_  flg _y);
     by newid x_  flg;
run;
data want(drop=flg newid x_ _y);
     set test2;
     by newid x_  flg;
                 id=tranwrd(newid,',',ifc(flg=1,'and','not',' '));
                 x=x_;
                 newy=_y;
     if first.x_;
run;
已有 1 人评分论坛币 收起 理由
admin_kefu + 50 热心帮助其他会员

总评分: 论坛币 + 50   查看全部评分

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-5 04:35