Hello People!!
I have a task to make PDF reports, one for each group name. Each Group name has to have two reports namely "Care Level Status" and "Case Open/close Status". Below code works absolutely fine in creating two PDF files one for each kind of Report.
/*Generating Reports*/
PROC SQL;
CREATE TABLE REPORT_3 AS
SELECT PARENT_GROUP, CARE_LEVEL_DESC, COUNT(DISTINCT(MHN)) AS MEMBER_COUNT
FROM WORK.CASES_FINAL_2015
GROUP BY PARENT_GROUP, CARE_LEVEL_DESC
ORDER BY PARENT_GROUP, CARE_LEVEL_DESC;
QUIT;
PROC SQL;
CREATE TABLE REPORT_4 AS
SELECT PARENT_SHP_GROUP_NUM, PARENT_GROUP, CASE_STATUS_DESC,
COUNT(CASE_STATUS_DESC) as total_cases
FROM WORK.CASES_FINAL_2015
GROUP BY PARENT_SHP_GROUP_NUM, PARENT_GROUP, CASE_STATUS_DESC;
QUIT;
/*Printing PDF*/
%let tdate = %sysfunc(date(),mmddyy10.);
%let ttime= %sysfunc(time(),timeampm11.);
ods escapechar='^';
options nodate nonumber colorprinting=yes;
ods pdf file="C:\Users\garga\Documents\SAS POC\Creating PDF\test3.pdf" style= styles.Ocean newfile=bygroup;
title j=right "^S={preimage='\\lap301006shp\Users\garga\Documents\SAS POC\Creating PDF\SECURITY.PNG'}";
title2 H=6.0 J=C F='Times New Roman' "Marshfield Clinic";
title3 H=3.0 J=C F='Times New Roman' "As of &tdate &ttime";
footnote1 H=1.5 J=L F='Times New Roman' "Creation Date: &tdate";
footnote2 H=1.5 J=L F='Times New Roman' "Please contact isdata@marshfieldclinic.org with any questions or concerns with this report.";
footnote3 h=10pt f=Arial j=right '^{thispage}';
proc report data=work.report_3
STYLE(REPORT) = [RULES = NONE FRAME = VOID ];
COLUMNS PARENT_GROUP care_level_desc MEMBER_COUNT;
define PARENT_GROUP/GROUP ORDER style(header)=[background = skyblue font_size = 12pt foreground = white];
define care_level_desc /'CASE STATUS' style(header)=[background = skyblue font_size = 12pt foreground = white];
Define MEMBER_COUNT /'TOTAL CASES' style(header)=[background = skyblue font_size = 12pt foreground = white];
BREAK AFTER PARENT_GROUP/ SUMMARIZE PAGE;
run;
proc report data=work.report_4
STYLE(REPORT) = [RULES = NONE FRAME = VOID ];
COLUMNS PARENT_GROUP CASE_STATUS_DESC TOTAL_CASES;
define PARENT_GROUP/GROUP ORDER style(header)=[background = skyblue font_size = 12pt foreground = white];
define CASE_STATUS_DESC /'CASE STATUS' style(header)=[background = skyblue font_size = 12pt foreground = white];
Define TOTAL_CASES /'TOTAL CASES' style(header)=[background = skyblue font_size = 12pt foreground = white];
BREAK AFTER PARENT_GROUP/ SUMMARIZE PAGE;
run;
ods pdf close;
What I am looking for is One PDF file for each group. Meaning to say if I have 30 groups in my table, then I want one PDf for each group and each PDF file will have two report tables. It doesn't matter if they are side to side or One after other.
Any help is much appreciated. I have been trying it for two days now and I have tried everything I could. There are other posts in the forum which helped but nothing is helping with this kind of specific task.
1. How are the reports different? If you had to copy/paste the code below and change it for each report, how would it change?
2. Have you looked at the NEWFILE option in ODS PDF? That's one option, the other is a MACRO. Here's a basic tutorial on how to write a macro.
If you need more examples, I suggest LexJansen or searching on here, there's a lot of examples of this type of reporting aroudn.
The two reports aren't much different. they both come from the same table (CASE_FINAL_2015). As you can see in the very beginning of the code, I have two proc SQL statements that are generating these two report tables.
The main table has following columns:
So report 1 is basically Counting distinct MHN for Care_Level_DESC for each Parent_Group
and report 2 is counting Case_Status_desc for each Parent Group.
If you had to copy/paste the code below and change it for each report, how would it change?
This is key to determine how to automate something.
If I had to change the code (speaking in most layman's term), the group number will change for each of the reports.
I used the code from the thread you shared. I get the concept, that I'll have to run the macro for the total number of Group count.
%macro reporting;
proc sql;
select distinct(PARENT_SHP_GROUP_NUM) into :grpnum SEPARATED by "|"
from work.report_3;
quit;
/*Need help here*/
/*Do for the length of Array -- grpnum*/
/*1) Make a PDF file for the Group Num*/
/*2) Run the report1 for the GroupNum*/
/*3) Run the report2 for the Group Num*/
/*end*/
%mend;
Can you please help me with the comment section?? I am not sure how do I parse each value of the array in Macro.
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.