I figured out how to do this part by using the retain statement to create a sequence number for ever loan number in my dataset. This insures that the same sequence number is tied to each loan.
data work.address;
set work.address;
by loan_number;
retain seq_id 0;
if first.loan_number then seq_id=seq_id + 1;
run;
Once that is done, then I can select the max and min into the variables and it prints the pdf files correctly (without treating the loan numbers as the min and max and printing all of the loan numbers that would be in between).
Here is the new code that works.
options orientation=landscape nodate nonumber;
ods results off;
%macro reporting;
proc sql;
select min(seq_id)format=best10.,max(seq_id) format=best10. into :firstgrp, :lastgrp
from work.address a1;
quit;
%do i = &firstgrp. %to &lastgrp.;
ods pdf file="/sae/aal_labapm/01/mortgage/msracq/DEVELOPMENT/history_epo_&i..pdf" style=htmlblue startpage=never bookmarklist=hide;
title "^S={font_size=14pt} LOAN HISTORY";
ods escapechar='^';
ods pdf text="^{style[just=left preimage='/sae/aal_labapm/01/mortgage/msracq/DEVELOPMENT/logo.jpg']}";
proc report data=work.address nowd;
where seq_id = &i.;
by loan_number; run;
proc report data=work.paytran nowd;
where seq_id = &i.;
by loan_number;
run;
ods pdf close;
%end;
%mend reporting;
%reporting;
However, now that the variable &i is the seq_id, that is what is printing as part of the .pdf file name instead of the loan number. Is there a way to print the loan number that is tied to that particular seq_id from the dataset in the .pdf file name?
... View more