c*****p 发帖数: 51 | 1 有如下数据
Seller Year var1 var2 var3
ABC 2005 0 0 0
ABC 2006 4 0 0
ABC 2007 17 1 1
EFG 2005 32 4 3
EFG 2006 45 8 5
EFG 2007 50 3 12
...
想变成以下格式新数据
Seller var1 var2 var3 var1 var2 var3 var1 var2 var3
ABC 0 0 0 4 0 0 17 1 1
EFG 32 4 3 45 8 5 50 3 1
...
新数据第2列到第4列为2005的var1到var3,第5列到第7列为2006的var1到var3,第8列到
第10列为2007的var1到var3.
我想用transpo |
d*******o 发帖数: 493 | 2 data one ;
input Seller $ Year var1 var2 var3;
var=var1;output; var=var2;output; var=var3;output;
drop var1-var3;
cards;
ABC 2005 0 0 0
ABC 2006 4 0 0
ABC 2007 17 1 1
EFG 2005 32 4 3
EFG 2006 45 8 5
EFG 2007 50 3 12
;
run;
proc sort data=one; by seller; run;
proc transpose data=one out=two prefix=var; by seller; var var; run; |
Y****a 发帖数: 243 | 3 transpose 里有 ‘by’ statement
proc transpose data=yourdatename out=outdataname;
var var1 - var3;
by Seller Year;
run;
proc transpose data=outdataname out=newdataname;
var col1;
by Seller;
run;
try something like this, you may need to drop a few variables
【在 c*****p 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 有如下数据 : Seller Year var1 var2 var3 : ABC 2005 0 0 0 : ABC 2006 4 0 0 : ABC 2007 17 1 1 : EFG 2005 32 4 3 : EFG 2006 45 8 5 : EFG 2007 50 3 12 : ... : 想变成以下格式新数据
|
i******r 发帖数: 323 | 4 data one ;
input Seller $ Year var1 var2 var3;
cards;
ABC 2005 0 0 0
ABC 2006 4 0 0
ABC 2007 17 1 1
EFG 2005 32 4 3
EFG 2006 45 8 5
EFG 2007 50 3 12
;
run;
proc sort data=one; by seller year; run;
proc transpose data=one out=two (drop=_name_);
by seller year;
var var1-var3; run;
proc sort ; by seller year;
run;
proc transpose data=two out=three (drop=_name_) prefix=var ;
by seller year;
var col1; run; |