楼主: xgnfly
3533 15

[原创博文] 请问如何进行以下数据转换 [推广有奖]

11
xgnfly 发表于 2010-5-23 21:29:52
5# xiaosanmao
遍历到B4

12
xiaosanmao 发表于 2010-5-23 22:03:20
xgnfly 发表于 2010-5-23 21:29
5# xiaosanmao
遍历到B4
哦,看到了,后边有些很小小的省略号,呵呵

13
bobguy 发表于 2010-5-23 23:13:30
xgnfly 发表于 2010-5-23 17:40
将以下数据
A1  B1 C1
A2  B2 C2
A3  B3 C3
A4  B4 C4
转换为
A1  B1 C1
A1  B1 C2
A1  B1 C3
A1  B1 C4
A1  B2 C1
A1  B2 C2
A1  B2 C3
A1  B2 C4
A1  B3 C1
A1  B3 C2
A1  B3 C3
A1  B3 C4
.
.
.
.
.
It seems you want to have a Cartesian Joint. Note the joint size grows VERY fast.

Here is an example.


data tmp;
input (a b c) (: $2.) ;
cards;
A1  B1 C1
A2  B2 C2
A3  B3 C3
A4  B4 C4
;

proc sql;
select t1.a, t2.b, t3.c
from tmp t1,tmp t2, tmp t3
order by 1, 2, 3
;
quit;
已有 1 人评分学术水平 收起 理由
crackman + 1 不错

总评分: 学术水平 + 1   查看全部评分

14
pobel 在职认证  发表于 2010-5-24 10:56:33
data test;
input a $ b $ c$ @;
cards;
A1  B1 C1
A2  B2 C2
A3  B3 C3
A4  B4 C4
;
run;

proc sql;
    create table result as
          select *
       from (select distinct a from test)
                ,(select distinct b from test)
                        ,(select distinct c from test)
           order by a,b,c;
quit;

15
xgnfly 发表于 2010-5-24 11:54:57
谢谢以上各位的帮助!!!!!!!!!!!!!

16
shenliang_111 发表于 2011-8-23 14:47:52
try this:
data a;
input a $ b $ c $;
cards;
A1  B1 C1
A2  B2 C2
A3  B3 C3
A4  B4 C4
;
data s;
if 0 then set a  nobs=nn;
do until(lastt);
set a(keep=a) end=lastt;
by a;
   do i=1 to nn;
   set a(keep=b) point=i;
      do j=1 to nn;
          set a(keep=c) point=j;
          output;
          end;
        end;
end;
run;
  

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-27 08:16