Sql 使用sas删除重复的列

Sql 使用sas删除重复的列,sql,sas,Sql,Sas,下面的代码可以工作吗 我正在从表中删除重复的列。想了想,我觉得有点困惑。我的代码看起来正常,但我担心看不见的错误 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(cpt

下面的代码可以工作吗

我正在从表中删除重复的列。想了想,我觉得有点困惑。我的代码看起来正常,但我担心看不见的错误

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
在数据步骤中不起作用


最好。

此网站不是代码审查服务,请改用。谢谢您的输入,Manu。阅读代码时,它应该能做到这一点