test name
1 a
2 b
3 c
的table 怎么样输出成这样的
test name
1 a
2 a_b
3 a_b_c
用proc sql步!
顺便问问各位前辈!我这样错在哪里???
proc sql;
create table test
(id numeric(10),
name varchar(10),
pid numeric(10)
)
;
insert into test(id,name,pid) values(1,'10',0);
insert into test(id,name,pid) values(2,'11',1);
insert into test(id,name,pid) values(3,'20',0);
insert into test(id,name,pid) values(4,'12',1);
insert into test(id,name,pid) values(5,'121',2);
select * from test start with id=1 connect by prior id=pid;
select * from test start with id=5 connect by prior pid=id;
如果可以用data步做的话还是比较简单的,SQL俺不是很熟悉;
data temp;
input var $ @@;
cards;
a b c d e f g h i j k l
;
run;
proc sql noprint;
select strip(put(count(*),best.)) into:nn from temp;
select strip(var) into :x1-:x&nn from temp;
quit;
%macro create;
data temp;
length var $256;
retain var;
var="&x1"; output;
%do i=2 %to &nn;
var=catx('_',var,"&&x&i"); output;
%end;
run;
%mend;
%create;
data temp;
input var $ @@;
cards;
a b c d e f g h i j k l
;
run;
data Temp;
set Temp;
length p$ 200.;
retain p;
if _n_=1 then p =var;
else p=catx('_',p,var);
proc print;
run;