Reputation: 123
Scenario: There is a dataset with a variety of variables sorted by a grouping variable (e.g. region). I would like to split up and output the data into “dashboard” style PDF 1-3 page reports for each value of grouping var (e.g. data on towns, by region).
The first page would contain one or two simple tables with a few key metrics that I want to highlight (e.g. a listing of several towns in the given region with some high-level status indicators, using some font/color formatting to highlight these overall results). Similar to dashboard look but without KPI graphics or anything like that - just a straight-forward, simple table with some key values.
The following 1-2 pages would contain additional data for the towns in the given region, displayed similar to how the data appears in the source dataset (a few additional selected variables, smaller font).
Once the report template/structure is designed, I would like to use it to output PDFs for my source dataset, with separate PDF for each value of a variable (e.g. by region), with PDF file names including region ID. Fancy graphics not a priority.
Questions:
Trying to figure out how feasible something like this would be in contrast to a similar hybrid dashboard-plus-detail type report in Excel, and trade-offs of Excel vs. SAS route. My understanding is SAS offers advantage in the ability to quickly transform/restructure data, something that would be tricky with formula-driven approach in Excel with a relatively large dataset.
I have experience programming in SAS and some experience using EG 5.1. Many thanks!
Upvotes: 0
Views: 661
Reputation: 1424
Right,
It is doable. There are a few ways to accomplish this task. The way I'd do is:
The ODS will let you break your report by Procs (one proc per page, or a group of procs in single page). Options are numerous.
here is a dummy example:
* Not necessary ;
data _null_;
wd = pathname('work');
call symputx('dir',wd);
put wd;
run;
* create lookup table;
proc sql;
create table lkup as select distinct sex from sashelp.class;
quit;
* create macro definition;
%macro report(gender);
ods pdf file="&dir./&gender..pdf" ;
title Report for group &gender.;
proc print data=sashelp.class;
where sex="&gender";
run;
proc means data=sashelp.class mean median;
var weight height;
where sex ="&gender";
ods pdf close;
%mend;
* invoke macro using lookup table to generate reports;
data _null_;
set lkup;
call execute('%report('||sex||')');
run;
Hope it helps
Upvotes: 2