I have to share my code: I know it's a closed topic but I think this could be useful. /************************************************************************************/ /* Descripcion general del programa: */ /* Suma las variables numericas de una tabla, sin especificar nombres. */ /* Autor : Saul Sanchez Sánchez */ /************************************************************************************/ data a; do i=1 to 100; a=abs(int(rand('NORMAL')*1000)); b=abs(int(rand('NORMAL')*1000)); c=abs(int(rand('NORMAL')*1000)); cl='a'||substr(left(compress(i)),1,1); output; end; run; data vars(where=(type='N')); length name $ 8 type $ 1; drop dsid i num rc; dsid=open("work.a","i"); num=attrn(dsid,"nvars"); do i=1 to num; name=varname(dsid,i); type=vartype(dsid,i); output; end; rc=close(dsid); run; data vars(keep=function); set vars; function='sum('||compress(name)||') as '||compress(name); run; proc sql; select function into :function separated by ',' from vars; quit; %put &function; proc sql; create table b as select cl, &function from a group by 1; run;
... View more