I've got some data that's just a long list of account numbers. I need it to be split up into batches of 100 each. Now, I can get it working normally, but I cannot get it working in a macro. The normal data steps look like this: data Batch_1;
set Accounts (firstobs=1. obs=100);
run;
data _null_;
if n=<100 then stop;
else call execute('data Batch_2; set Accounts (firstobs=101 obs=200); run;');
stop;
set Accounts nobs=n;
run;
data _null_;
if n=<200 then stop;
else call execute('data Batch_3; set Accounts (firstobs=201 obs=300); run;');
stop;
set Accounts nobs=n;
run; That works fine. It'll only create the amount of data sets I actually need depending on the amount of account numbers I have that day. But I wanted to put it into a macro and made it look like this: %Macro Batches;
%do i=1 %to 3;
data _null_;
%if n=<((&i.*100)-100) %then %do;
stop;
%end;
%else %do;
call execute('data Batch_&i.; set Accounts (firstobs=((&i.*100)-99) obs=(&i.*100)); run;');
stop;
%end;
set Accounts nobs=n;
run;
%END;
%mend Batches;
%Batches() But I get the following error: 1 + data Batch_1; set Accounts (firstobs=((1*100)-99) obs=(1*100)); run; _ 23 ERROR 23-7: Invalid value for the FIRSTOBS option. 1 !+data Batch_1; set Accounts (firstobs=((1*100)-99) obs=(1*100)); run; _ 23 ERROR: Invalid number conversion on (. ERROR: Invalid number conversion on (. ERROR 23-7: Invalid value for the OBS option. So is it because I can't us a calculated value for firstobs and obs= or is it something else? Is there any way to make this work or another way to make a macro do the same thing? I obviously need to make far more than just 3 batches normally, which is why I'd prefer a macro. Thanks 🙂
... View more