I guess Tom's answer is a great one. There is really no need to iterate in this case. If you insist using iteration as you did, you can either use proc append, the SQL Drop mentioned in Reeza should be outside the loop and you might have a warning if the dataset was not exist at first! And please let me point out something (no offense): %let mylist = 123:444:647; %do i=1 to 3 by 1; /*(%to %by??)*/ %let var_i = %scan(&mylist,&i,":"); /* (:, no need for " ")*/ proc sql noprint; select organisation :into org_number separated by "," from report.organisations where xy=&var_i; /*(do you need " " here??)*/ quit; data work.myfullresult; set report.mybigdata; where org in (org_number); my_new_var = %var_i; /*&var_i*/ drop my_old_var; run; %end;
... View more