In the code below my intent is to have the two proc prints print on either the same page or one on page one & the other on page two of a pdf document. I have by groups on both proc print statements, but what I end up with is 50+ pdfs. 2 per by group, one with the 1st proc print and one with the 2nd proc print. Is there a way to have them both print on the same, and keep the by groupings? I have read several articles using regions, listings and/or macros and none would give me what I was really looking for, and I think it is my groupings messing it up. Tips/ideas?
ods pdf file="\\MCC-DATA\IEDATA\Projects\CE_Evals\&YEAR.&QUARTER.\summary.pdf" newfile=bygroup startpage=yes notoc style=MyJournal3; OPTIONS NONUMBER NODATE; TITLE "Summary Results for Continuing Education Courses Taught During &YEAR. - &QUARTER."; PROC PRINT DATA=WORK.RESULTS_TOTALS LABEL WIDTH=FULL NOOBS; BY TITLE INSTRUCTOR; WHERE QUESTION <= 'Q14'; VAR QUESTION SA PERCENT_SA A PERCENT_A D PERCENT_D SD PERCENT_SD; LABEL SA = 'Strongly Agree' PERCENT_SA = '% Strongly Agree' A = 'Agree' PERCENT_A = '% Agree' D = 'Disagree' PERCENT_D = '% Disagree' SD = 'Strongly Disagree' PERCENT_SD = '% Strongly Disagree' TITLE = 'Course' INSTRUCTOR = 'Instructor'; RUN; PROC PRINT DATA=WORK.RESULTS_TOTALS LABEL NOOBS; BY TITLE INSTRUCTOR; WHERE QUESTION = 'Q15'; VAR QUESTION EX PERCENT_EX GD PERCENT_GD AV PERCENT_AV BAV PERCENT_BAV PR PERCENT_PR; LABEL EX = 'Excellent' PERCENT_EX = '% Excellent' GD = 'Good' PERCENT_GD = '% Good' AV = 'Average' PERCENT_AV = '% Average' BAV = 'Below Average' PERCENT_BAV = '% Below Average' PR = 'Poor' PERCENT_PR = '% Poor'; RUN; ods pdf close;
You are actually attempting to interleave the results from two procedures if I understand what you are saying. First by group values from the first proc print followed by the same by group of the second proc print, then the next by group from the first proc print and then the second by group from the second proc print.
If that is the case then you have more work ahead. Try this untested code as I don't have your data set:
proc sql;
create table Control as
select distinct title,Instructor
from work.results_totals;
quit;
data _null;
set control;
Length lstr $ 200;
call execute ('PROC PRINT');
call execute ('DATA=WORK.RESULTS_TOTALS LABEL WIDTH=FULL NOOBS;');
lstr = catx(' ','Title','"Title=',title,'Instructor=',Instructor,'";');
call execute (Lstr );
lstr = catt('Where Question <="Q14" and Title="',title,'" and Instructor="',Instructor,'";');
call execute (Lstr );
call execute ('VAR QUESTION SA PERCENT_SA A PERCENT_A D PERCENT_D SD PERCENT_SD;');
call execute ("LABEL SA = 'Strongly Agree'");
call execute ("PERCENT_SA = '% Strongly Agree'");
call execute ("A = 'Agree'");
call execute ("PERCENT_A = '% Agree'");
call execute ("D = 'Disagree'");
call execute ("PERCENT_D = '% Disagree'");
call execute ("SD = 'Strongly Disagree'");
call execute ("PERCENT_SD = '% Strongly Disagree'");
call execute ("TITLE = 'Course'");
call execute ("INSTRUCTOR = 'Instructor';");
call execute ("RUN;");
call execute ('PROC PRINT');
call execute ('DATA=WORK.RESULTS_TOTALS LABEL NOOBS;');
lstr = catx(' ','Title','"Title=',title,'Instructor=',Instructor,'";');
call execute (Lstr );
lstr = catt('Where Question ="Q15" and Title="',title,'" and Instructor="',Instructor,'";');
call execute (Lstr );
call execute ("VAR QUESTION EX PERCENT_EX GD PERCENT_GD AV PERCENT_AV BAV PERCENT_BAV PR PERCENT_PR;");
call execute ("LABEL EX = 'Excellent'");
call execute ("PERCENT_EX = '% Excellent'");
call execute ("GD = 'Good'");
call execute ("PERCENT_GD = '% Good'");
call execute ("AV = 'Average'");
call execute ("PERCENT_AV = '% Average'");
call execute ("BAV = 'Below Average'");
call execute ("PERCENT_BAV = '% Below Average'");
call execute ("PR = 'Poor'");
call execute ("PERCENT_PR = '% Poor';");
call execute ("RUN;");
run;
The option newfile=bygroup instructs ODS to create one file for each by group.
Remove it.
You are actually attempting to interleave the results from two procedures if I understand what you are saying. First by group values from the first proc print followed by the same by group of the second proc print, then the next by group from the first proc print and then the second by group from the second proc print.
If that is the case then you have more work ahead. Try this untested code as I don't have your data set:
proc sql;
create table Control as
select distinct title,Instructor
from work.results_totals;
quit;
data _null;
set control;
Length lstr $ 200;
call execute ('PROC PRINT');
call execute ('DATA=WORK.RESULTS_TOTALS LABEL WIDTH=FULL NOOBS;');
lstr = catx(' ','Title','"Title=',title,'Instructor=',Instructor,'";');
call execute (Lstr );
lstr = catt('Where Question <="Q14" and Title="',title,'" and Instructor="',Instructor,'";');
call execute (Lstr );
call execute ('VAR QUESTION SA PERCENT_SA A PERCENT_A D PERCENT_D SD PERCENT_SD;');
call execute ("LABEL SA = 'Strongly Agree'");
call execute ("PERCENT_SA = '% Strongly Agree'");
call execute ("A = 'Agree'");
call execute ("PERCENT_A = '% Agree'");
call execute ("D = 'Disagree'");
call execute ("PERCENT_D = '% Disagree'");
call execute ("SD = 'Strongly Disagree'");
call execute ("PERCENT_SD = '% Strongly Disagree'");
call execute ("TITLE = 'Course'");
call execute ("INSTRUCTOR = 'Instructor';");
call execute ("RUN;");
call execute ('PROC PRINT');
call execute ('DATA=WORK.RESULTS_TOTALS LABEL NOOBS;');
lstr = catx(' ','Title','"Title=',title,'Instructor=',Instructor,'";');
call execute (Lstr );
lstr = catt('Where Question ="Q15" and Title="',title,'" and Instructor="',Instructor,'";');
call execute (Lstr );
call execute ("VAR QUESTION EX PERCENT_EX GD PERCENT_GD AV PERCENT_AV BAV PERCENT_BAV PR PERCENT_PR;");
call execute ("LABEL EX = 'Excellent'");
call execute ("PERCENT_EX = '% Excellent'");
call execute ("GD = 'Good'");
call execute ("PERCENT_GD = '% Good'");
call execute ("AV = 'Average'");
call execute ("PERCENT_AV = '% Average'");
call execute ("BAV = 'Below Average'");
call execute ("PERCENT_BAV = '% Below Average'");
call execute ("PR = 'Poor'");
call execute ("PERCENT_PR = '% Poor';");
call execute ("RUN;");
run;
This is getting me towards what I am looking for!! Thank you so much! One last question, is it possible to do a file break after the end of the last call execute? This is putting the file in the correct order which, is great because then even if I have to manually break up the pdf file, that's a lot easier than reorganizing or recompiling files.
I don't use PDF much put I think if you add:
Call execute("ODS PDF Startpage=Now;"); that will insert a page break after the second proc print.
But you will need to have
Call execute ("ODS PDF Startpage=No;"); before the first Proc print to give a chance to get both proc print on one page (or minimum space between them if they run longer).
This worked perfectly, thank you so much!!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.