全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1282 7
2012-09-27

Id

a

b

c

d

e

f

1

1

1

36

37

84

89

1

0

0

62

22

55

19

1

1

0

13

75

74

83

2

1

0

33

76

48

43

2

1

0

29

71

73

22

3

1

1

25

33

100

22

3

0

1

77

92

16

68

4

0

1

20

61

14

20

5

0

0

5

14

70

92

5

1

1

85

21

50

51

6

1

1

75

100

56

28

6

0

0

68

94

56

28


二维码

扫码加我 拉你入群

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

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

全部回复
2012-9-27 17:32:01
数据如上,希望得到的结果是:同样的Id,把多条数据和并成一条,也就是说,呈现下面这种形式 (或者更好的形式):

Id a1 b1 c1 d1 e1 f1 a2 b2 c2 d2 e2 f2 a3 b3 c3 d3 e3 f3
1 1 0 56 85 18 35 0 1 81 44 34 57 1 1 32 13 6 11
2 1 0 60 71 86 48 1 1 67 75 65 83      
3 1 0 34 17 94 24 0 1 59 35 97 39      
4 0 1 49 9 7 69            
5 0 1 23 67 63 21 1 1 37 79 96 60      
6 1 1 12 6 66 32 0 0 81 97 83 18            

万分感激
二维码

扫码加我 拉你入群

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

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

2012-9-27 19:11:45
data test;
  input Id $        a         b        c        d        e        f;
  cards;
1        1        1        36        37        84        89
1        0        0        62        22        55        19
1        1        0        13        75        74        83
2        1        0        33        76        48        43
2        1        0        29        71        73        22
3        1        1        25        33        100        22
3        0        1        77        92        16        68
4        0        1        20        61        14        20
5        0        0        5        14        70        92
5        1        1        85        21        50        51
6        1        1        75        100        56        28
6        0        0        68        94        56        28
;

data test;
    set test;
        by id;
        if first.id then n=1;
        else n+1;
run;

proc transpose data=test out=test1;
   by id n;
   var a b c d e f;
run;

data test2;
    set test1;
        _name_=cats(_name_,n);
run;

proc transpose data=test2 out=test3;
   by id;
   var col1;
   id _name_;
run;
二维码

扫码加我 拉你入群

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

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

2012-9-28 09:12:36
pobel 发表于 2012-9-27 19:11
data test;
  input Id $        a         b        c        d        e        f;
  cards;
十分感谢!
二维码

扫码加我 拉你入群

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

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

2012-9-28 09:53:12
复制代码
Hopefully it works. if it does, i will put it to my blog tomorrow. jingju
二维码

扫码加我 拉你入群

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

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

2012-9-28 10:27:45
jingju11 发表于 2012-9-28 09:53
Hopefully it works. if it does, i will put it to my blog tomorrow. jingju
Thanks a lot.
one quick question, in your code, do you suppose that the 'had' dataset you set is the orignal dataset which is expected to be transposed?
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群