Hi , Here is an approach of getting the desired output but from datastep without the use of proc sql. data class; set sashelp.class; run; data columns; set sashelp.vcolumn; where libname='WORK' and memname='CLASS' and 2<=varnum<=5; call symputx("keep"||trim(put(varnum,1.)),name); run; %put &keep2 &keep3; %macro vars; data class1; set class; keep %do j=2 %to 5; &&keep&j %end;; run; %mend; %vars hope it helps. Thanks, Jag
... View more