wmqy2004
本人现有一数据集需要进行整理(将aa转换为bb格式),特求助于各位高手,谢谢!
data aa;
input id x1-x4 y1-y4;
cards;
1 11 12 13 14 15 16 17 18
2 21 22 23 24 25 26 27 28
3 31 32 33 34 35 36 37 38
4 11 12 13 14 15 16 17 18
;run;
data bb;
input id x1 y1 x2 y2 x3 y3 x4 y4;
cards;
1 11 15 12 16 13 17 14 18
2 21 25 22 26 23 27 24 28
3 31 35 32 36 33 37 34 38
4 11 15 12 16 13 17 14 18
;run;
各位大侠,可一定要帮帮我啊,不胜感谢!
oliyiyi
你不是转了吗?你想如何?没明白.
swufemarbury
先导成excel格式,然后在excel中调整,然后再导成sas格式
办法有点麻烦
wmqy2004
[quote]引用第1楼oliyiyi于2007-06-11 21:11发表的“”:
你不是转了吗?你想如何?没明白.[/quote]
对不起,可能是我没说明白,我是需要将aa的格式转换成bb的格式。
wmqy2004
[quote]引用第2楼swufemarbury于2007-06-11 22:32发表的“”:
先导成excel格式,然后在excel中调整,然后再导成sas格式
办法有点麻烦[/quote]
谢谢您的回复,只是我的数据集中有变量2133个,转换成excel中是不行的,因为excel只能容纳255列。
非常希望能够得到各位高手的帮助,谢谢!
swufemarbury
2007 的容量比较巨大
wmqy2004
[quote]引用第5楼swufemarbury于2007-06-11 23:48发表的“”:
2007 的容量比较巨大[/quote]
谢谢Icon,我明天就去买张office2007光盘。
neige
...........
oliyiyi
[quote]引用第4楼wmqy2004于2007-06-11 23:01发表的“”:
谢谢您的回复,只是我的数据集中有变量2133个,转换成excel中是不行的,因为excel只能容纳255列。
非常希望能够得到各位高手的帮助,谢谢![/quote]
可是上面不是只有8个变量吗?
告诉我你数据的变量命,我帮你写程序!
wmqy2004
[quote]引用第8楼oliyiyi于2007-06-12 00:31发表的“”:
可是上面不是只有8个变量吗?
告诉我你数据的变量命,我帮你写程序![/quote]
我的变量名为id a1-a1536 b1-b1536,即变量有3073个,记录有1056个,再次向您表示感谢。
另外,麻烦您帮我考虑一下如何将cc格式的数据转换成dd格式的数据,谢谢!
data cc;input id id1 x1 x2 x3 x4;cards;
1 1 3 4 5 6
1 2 4 5 6 5
1 3 6 5 4 3
2 1 5 4 3 2
2 2 4 5 6 7
2 3 8 7 5 6
;run;
data dd;input id x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12;
cards;
1 3 4 5 6 4 5 6 5 6 5 4 3
2 5 4 3 2 4 5 6 7 8 7 5 6
;run;
zhanjian
data bb;
set aa;
retain id x1 y2 x2 y2 x3 y3 x4 y4 ;
run;
zhanjian
data cc;
input id id1 x1 x2;
cards
;
1 1 12 13
1 2 13 15
2 1 11 12
2 2 13 14
3 1 12 11
3 2 13 11
;
run;
data dd (drop = id1);
merge cc(where= (id1=1)) cc(where= (id1=2) rename =(x1 = x3 x2 = x4));
by id;
run;
可以模仿此方法
zhanjian
data cc;input id id1 x1 x2 x3 x4;cards;
1 1 3 4 5 6
1 2 4 5 6 5
1 3 6 5 4 3
2 1 5 4 3 2
2 2 4 5 6 7
2 3 8 7 5 6
;run;
data dd ;
merge cc(where=(id1=1)) cc(where=(id1=2)rename=(x1=x5 x2=x6 x3=x7 x4=x8))
cc(where=(id1=3) rename=(x1=x9 x2=x10 x3=x11 x4=x12));
by id;
drop id1;
run;
oliyiyi
明白你的意思了,就是因为变量多,不好改动,其实只需要用一下宏就可以了,也许还有更简单的办法,呵呵!
代码如下:
%let num=1536;
%macro create;
%do i=1 %to #
x_&i=x&i;
y_&i=y&i;
%end;
%mend create;
data bb;
set aa;
%create
drop x1-x#
drop y1-y#
run;
proc print data=bb;
run;
oliyiyi
cc变dd,上两楼就行,如果变量很多,用宏加数组都能搞定!
abel
in R
1) newdata <- data[, c(seq(1, n, by=2), seq(2, n ,by=2))]
2) newdata <- reshape(data, ......)