proc sort data=a out=b;
by id;
data b1;
set b;
if id=001 then count1+1;
else if id=002 then count2+1;
else if id=003 then count3+1;
proc transpose data=b out=b1;
run;
data c(drop=i);
set b1;
array co(*) col1-col9;
if _n_=3 then do;
do i=1 to 9;
if i<=3 then co(i)=co(2);
else if i<=7 then co(i)=co(3+3);
else co(i)=co(7+2);
end;
end;
proc transpose data=c out=b2;
proc print data=b2(drop=_name_);run;作者: shiyiming 时间: 2009-10-29 14:38 标题: Re: 帮忙:表格制作问题 这是我做的另一种方法 但还没完善 做不下去了 高手帮忙指点指点 初学sas 献丑了
data a;
input id value1;
value2=value1;
cards;
001 0.1
001 0.2
001 0.3
002 0.4
002 0.5
002 0.6
002 0.7
003 0.8
003 0.9
;
data a1 a2 a3;
set a;
if id=001 then output a1;
else if id=002 then output a2;
else if id=003 then output a3;
%macro aa(par1,par2,n,m,t);
proc transpose data=&par1 out=&par2;
var id value1 value2;
run;
data b(drop=i);
set &par2;
array co(&n) col1-col&n;
if _n_=&m then do;
do i=1 to &n;
co(i)=co(&t);
end;
end;
proc transpose data=b out=c;
run;
proc print data=c(drop=_name_);
run;
%mend aa;
%aa(a1,aa1,3,3,2)作者: shiyiming 时间: 2009-10-29 17:08 标题: Re: 帮忙:表格制作问题 [code:1dkbm1rx]data a;
input id value1 ;
cards;
001 0.1
001 0.2
001 0.3
002 0.4
002 0.5
002 0.6
002 0.7
003 0.8
003 0.9
;
run;
data b;
set a;
by id;
if first.id then count=0;
count+1;
if id='001' and count=2 then output;
if id='002' and count=3 then output;
if id='003' and count=2 then output;
rename value1=value2;
drop count;
run;