This macro works fine. I am trying to create a macro and pass on the ID to rest of the program. data WANT (keep=id); set have nobs=_nobs_; count = ceil(_n_ / 1000); run; Dataset want has column called ID( 6500 ids).Created a variable called count, setting to 1000 ids in each count. Created a global variable Check. This macro works fine when the loop is 1 to 7 (each check contains 1000), but If I increment from 7 to 10, the rest of the 3 increments (8,9,10) gets repeated (having the same set of ids from the last iterations). I need help here. I wanna tell the macro to stop working when it reaches the last obs in the dataset WANT. Iteration J should stop looping. When it reaches the last observation , the iteration also should stop. if its 7 or 8 then stop till 7 or 8. I dont want to change the iterations from 10 to 7. Because I want to use the same program again & my next dataset have more ids( more than 8000). I dont want to keep changing the numbers in interation. %macro tests; %do j = 1 % to 10 ; %global check_&j; proc sql noprint; select id into: check separated by "," from WANT where count = &j; quit; %let check_&j = (&check); %put check_&j= &&check_&j; %end; %mend; %create_tests;
... View more