下面的代码可以工作吗?
我正在从我的表中删除重复列。想了想,我有点糊涂了。我的代码看起来可以工作,但我担心看不见的错误。
proc sql;
create table toto
as select min(nomvar) as nomvar,count(intitule) as compte
from dicoat
group by intitule
having count(intitule) > 1;
data work.toto;
set toto;
do while(cpte>=1);
proc sql;
delete from dicoat where nomvar in (select nomvar from toto);
insert into toto
select min(nomvar) as nomvar,count(intitule) as compte from dicoat
group by intitule
having count(intitule) > 1;
end;
run;
data _null_;
file tempf;
set toto end=lastobs;
if _n_=1 then put "data aat;set aat (drop=";
put var /;
if lastobs then put ");run;";
run;
%inc tempf;
filename tempf clear;
经过一番思考和质疑(好吧-很多质疑),我的一个熟人帮我解决了这个问题
proc sort data=dicoat;
by title;
run;
data _null_;
set dicoat end=last;
length dropvar $1000;
retain dropvar;
by title;
if not first.title then dropvar = catx(' ',dropvar,nomvar);
if last then call symput('dropvar',trim(dropvar));
run;
data aat;
set aat(drop=&DROPVAR.);
run;
它应该执行删除重复列的技巧。不,proc sql
不能在数据步长内工作。
。