I've written a program that reads a files and creates multiple reports on a single PDF page. It is macro driven, so that many separate report files can be generated at once.
This worked fine until I started to have the PDF file destination on a SharePoint site. Now, instead of just writing each pdf, it opens Acrobat and asks me to respond to a prompt before it will generate the next PDF. This would not be so bad if I were only generating a few PDFs, but with more than a hundred, responding to a prompt for each one gets old. Thoughts?
The code and a screen print of the prompt are below:
/* clinic_report_printing.sas */
footnote;
footnote2;
footnote3;
option spool;
proc sort data=clinic_score4;by location;run;
*Options symbolgen mlogic nomprint nomfile bottommargin=.75in;
/* Macro to SCAN through DATALOG */
%MACRO SCANLOOP(SCANFILE,field1,field2);
/* First obtain the number of */
/* records in DATALOG */
DATA _NULL_;
IF 0 THEN SET &SCANFILE NOBS=X;
CALL SYMPUT('RECCOUNT',X);
STOP;
RUN;
/* loop from one to number of */
/* records */
%DO I=1 %TO &RECCOUNT;
/* Advance to the Ith record */
DATA _NULL_;
SET &SCANFILE (FIRSTOBS=&I);
/* store the variables */
/* of interest in */
/* macro variables */
CALL SYMPUT('print_file',&field1);
CALL SYMPUT('location',&field2);
STOP;
RUN;
/* now perform the tasks that */
/* wish repeated for each */
/* observation */
ods listing close;
title &monthtext ' Productivity for ' &location ;
ods pdf file= &print_file;
options orientation=landscape papersize=letter linesize=200 nocenter;
ods graphics / reset=all scale border=on;
/* report #1 */
ods escapechar = '^';
ods layout start;
proc sort data=clinic_score4;by location;run;
ods region x=.5in y=0in;
proc report data=clinic_score4 nowd split="*"
style(report)=[background=white cellspacing=2 borderwidth=1pt bordercolor=black foreground=black]
style(header)=[background=#E6E6E6]
style(column)=[cellspacing=2 borderwidth=1pt bordercolor=black]
;
where location=&location and month=&currmonth;
column ("This Month's Appointments" allocated booked pct_book total_appts arrive npv_total bump cancel noshow /*hrs_att svc_att*/);
define allocated / 'Hours Allocated' format=8. style(column)=[just=center background=lightyellow];
define booked / 'Hours Booked' format=7. style(column)=[just=center background=lightyellow];
define pct_book / '% Hours Booked' format=percent7. style(column)=[just=center background=lightyellow];
define total_appts / '# Appts*Scheduled' f=6.0 style(column)=[just=center cellwidth=.8in background=lightyellow] ;
define arrive / '# Arrived*Appointments' format=8. style(column)=[just=center background=lightyellow];
define npv_total / '# NPV*Scheduled' f=6. style(column)=[ just=center cellwidth=.8in background=pink];
define cancel / '# Cancelled*Appointments' format=8. style(column)=[just=center background=#FFEBD6];
define noshow / '# No-Show*Appointments' format=8. style(column)=[just=center background=lightblue];
define bump / '# Bumped*Appointments' format=8. style(column)=[just=center background=#D4B8DC];
run;
ods region x=.5in y=1.5in;
proc report data=clinic_score4 nowd split='*'
style(report)=[background=white cellspacing=2 borderwidth=1pt bordercolor=black foreground=black]
style(header)=[background=#E6E6E6]
style(column)=[cellspacing=2 borderwidth=1pt bordercolor=black]
;
where location=&location and month=&currmonth;
column
("New Patient Visits" pct_npv_7
pct_npv_14)
('Bumped Appts' pct_bmpd_rnd)
('Cancelled' pct_can_lt2)
('No-Shows'
pct_noshow
pct_fu_noshow
pct_npv_noshow_lt14
pct_npv_noshow_gt14)
;
define pct_npv_7/ '% NPV*Scheduled*<= 7 Days' f=percentn10. style(column)=[ just=center cellwidth=1in background=pink] ;
define pct_npv_14 / '% NPV*Scheduled*< 14 Days' f=percentn10. style(column)=[ just=center cellwidth=1in background=pink] ;
define pct_bmpd_rnd / '% of Scheduled*That Were*Bumped' f=percentn10. style(column)=[ just=center cellwidth=1.3in background=#D4B8DC] ;
define pct_noshow /'% of Scheduled*That Were*No-Shows' f=percentn10. style(column)=[just=center cellwidth=1.3in background=lightblue];
define pct_can_lt2 / '% of Scheduled*That Cancel*within 2 days' f=percentn10. style(column)=[just=center cellwidth=1.3in background=#FFEBD6] ;
define pct_fu_noshow / '% of Scheduled*F/U Visits*that No-Show' f=percentn10. style(column)=[cellwidth=1.3in just=center background=lightblue] ;
define pct_npv_noshow_lt14 / '% NPV*F/U Sched*<=14 Days' f=percentn10. style(column)=[cellwidth=1in just=center background=lightblue] ;
define pct_npv_noshow_gt14 / '% NPV*F/U Sched*>14 Days' f=percentn10. style(column)=[cellwidth=1in just=center background=lightblue] ;
;
run;
ods graphics on / imagemap=on;
proc sort data=clinic_score4;by location month;run;
ods region x=.5in y=3.25in height=3.25in width=4.25in;
title;
proc sgplot data=clinic_score4;
where location=&location and &bmonth <= month <= &emonth;
series x=month y=total_appts / legendlabel="Appts Scheduled" lineattrs=(color=blue) /* datalabel=a markers*/;
series x=month y=arrive / legendlabel="Appts Attended" lineattrs=(color=red) /*datalabel=p markers*/ ;
series x=month y=cancel / legendlabel="Appts Cancelled" lineattrs=(color=green) /* datalabel=a markers*/;
series x=month y=noshow / legendlabel="Appts No-Showed" lineattrs=(color=black) /*datalabel=p markers*/ ;
xaxis type=discrete label="Month";
yaxis label="Appointments" /* values=(0 to 150 by 10)*/;
run;
ods region x=5.5in y=3.25in height=3.25in width=4.25in;
title;
proc sgplot data=clinic_score4;
where location=&location and &bmonth <= month <= &emonth;
series x=month y=mean / legendlabel="Mean Days to Close Encounters" lineattrs=(color=red);
series x=month y=npv_sched_14 / legendlabel="NPV Scheduled w/in 14 Days" lineattrs=(color=purple) /* datalabel=a markers*/;
series x=month y=pct_npv_noshow_lt14 / legendlabel="NPV Follow-ups Scheduled w/in 14 Days that No-Show" lineattrs=(color=orange) /*datalabel=p markers*/ ;
xaxis type=discrete label="Month";
yaxis label="Visits/Days" /* values=(0 to 150 by 10)*/;
run;
ods layout end;
ods pdf close;
%END;
%MEND SCANLOOP;
/* Call SCANLOOP */
%SCANLOOP(clinic_score4,print_file,m_loc);
Have you turned off View Results as they are generated option?
IT WORKED! I am putting you in my will!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.