Hi SAS Community, Please find the dummy code with my question in below: %macro test; %do i = 1 %to n; data _null_; Create macro variables name1, name2, ... name<n> from a pre-made data set according to the variable i. set DS1&i end = final; call symput('name' || strip(_n_),strip(names)); if FINAL then call symput('total',_n_); run; data test&i; set DS2; There was already a variable "assign" with some values filled in DS2. I plan to fill out the blanks with the value of the macro &&name&m. Checking if &&name&m satisfies certain condition in ascending order, if not, check &&name%eval(&m+1) and so on, until the blank is filled then exist the do loop (with m). retain assign; do m = 1 to &total; if missing(assign) = 1 and _n_ = &i then do; assign1 = "&&name&m"; output; end; run; %end; %mend; The condition for &&name&m couldn't be checked outside of the data step, because the value of the DS2 is involved in the condition checking. Could anyone please help? Or if there's any other approaches that you suggest. Thank you!
... View more