I am new to ODS reporting. I have a project in which I need to create multiple pager PDF. So want to know how can I create multiple pager PDF. Also I want to know how can we control the page size so that all pages have same indentation of the headings and logos. Also I have to create the main cover page and on the next page it have to show contents.
Also attached is the sample table that I need to replicate it in the PDF. Any help is strongly appreciated.
It's definitely possible just a lot of work.
This shows you how to create a quick report and pipe it to PDF, note the traffic lighting in the report. You'll need to learn a few things:
I would recommend reading up on each topic specifically and then mapping out your process step by step and automating it that way. Another option, if your PDF title page and table of contents are static, you can create those separately outside of SAS and append them to your reported data if needed. Search for references for each of the topics above at lexjansen.com for many resources.
data comp (keep=title unit class count month category);
set sashelp.class;
title=name;
unit=age;
class=sex;
count=height;
month=weight;
if age in (11,12) then category=1;
else if age in (13,14) then category=2;
else if age in (15) then category=3;
else category=4;
run;
proc format;
value colorflag 1='lightblue'
2='lightyellow'
3='lightgreen'
4='pink';
run;
** It is better to only have 1 column statement so I took out the multiple column statements;
title; footnote;
ods pdf file='/home/fkhurshed/Demo1/colorcode.pdf' style=meadow;
proc report data= comp nowd spanrows style= {background= white foreground=black };
column title unit class count month category dummy;
** using ORDER=DATA does not have any impact without a;
** usage of ORDER or GROUP on the report item -- so I took it off;
** remember that default usage for character vars is DISPLAY;
** and default usage for numeric vars is ANALYSIS SUM;
** so the CALL DEFINE "reference" for COUNT is COUNT.SUM and for
** MONTH is MONTH.SUM;
define title/ 'title';
define unit/ "unit";
define class/ 'class' ;
define count/ 'count' ;
define month/ 'month' ;
/* hidden column containing color flag*/
/* will use NOPRINT later */
define category/ display ;
define dummy / computed;
/* dummy column for traffic lighting*/
/* traffic light the data columns based on category*/
compute dummy/character length=100;
** make a temp variable big enough to hold whole style string;
length svar $100;
if category in (1,2,3,4) then do;
svar = catt('style={background=', put (category, colorflag.),'}');
dummy = svar;
** need different column reference for numeric vs character;
** if COUNT and MONTH had been a usage or display, then it would have been OK;
** to use the simple name. ;
call define ('count.sum' , 'style', svar);
call define ('month.sum', 'style', svar);
call define ('class','style',svar);
end;
endcomp;
run;
ods pdf close;
@nishant77goel wrote:
I am new to ODS reporting. I have a project in which I need to create multiple pager PDF. So want to know how can I create multiple pager PDF. Also I want to know how can we control the page size so that all pages have same indentation of the headings and logos. Also I have to create the main cover page and on the next page it have to show contents.
Also attached is the sample table that I need to replicate it in the PDF. Any help is strongly appreciated.
It's definitely possible just a lot of work.
This shows you how to create a quick report and pipe it to PDF, note the traffic lighting in the report. You'll need to learn a few things:
I would recommend reading up on each topic specifically and then mapping out your process step by step and automating it that way. Another option, if your PDF title page and table of contents are static, you can create those separately outside of SAS and append them to your reported data if needed. Search for references for each of the topics above at lexjansen.com for many resources.
data comp (keep=title unit class count month category);
set sashelp.class;
title=name;
unit=age;
class=sex;
count=height;
month=weight;
if age in (11,12) then category=1;
else if age in (13,14) then category=2;
else if age in (15) then category=3;
else category=4;
run;
proc format;
value colorflag 1='lightblue'
2='lightyellow'
3='lightgreen'
4='pink';
run;
** It is better to only have 1 column statement so I took out the multiple column statements;
title; footnote;
ods pdf file='/home/fkhurshed/Demo1/colorcode.pdf' style=meadow;
proc report data= comp nowd spanrows style= {background= white foreground=black };
column title unit class count month category dummy;
** using ORDER=DATA does not have any impact without a;
** usage of ORDER or GROUP on the report item -- so I took it off;
** remember that default usage for character vars is DISPLAY;
** and default usage for numeric vars is ANALYSIS SUM;
** so the CALL DEFINE "reference" for COUNT is COUNT.SUM and for
** MONTH is MONTH.SUM;
define title/ 'title';
define unit/ "unit";
define class/ 'class' ;
define count/ 'count' ;
define month/ 'month' ;
/* hidden column containing color flag*/
/* will use NOPRINT later */
define category/ display ;
define dummy / computed;
/* dummy column for traffic lighting*/
/* traffic light the data columns based on category*/
compute dummy/character length=100;
** make a temp variable big enough to hold whole style string;
length svar $100;
if category in (1,2,3,4) then do;
svar = catt('style={background=', put (category, colorflag.),'}');
dummy = svar;
** need different column reference for numeric vs character;
** if COUNT and MONTH had been a usage or display, then it would have been OK;
** to use the simple name. ;
call define ('count.sum' , 'style', svar);
call define ('month.sum', 'style', svar);
call define ('class','style',svar);
end;
endcomp;
run;
ods pdf close;
@nishant77goel wrote:
I am new to ODS reporting. I have a project in which I need to create multiple pager PDF. So want to know how can I create multiple pager PDF. Also I want to know how can we control the page size so that all pages have same indentation of the headings and logos. Also I have to create the main cover page and on the next page it have to show contents.
Also attached is the sample table that I need to replicate it in the PDF. Any help is strongly appreciated.
You can either combine them after the fact or you can generate multiple PDF page by default.
ods pdf file='/demo/start.pdf';
proc print data=sashelp.class;
run;
proc print data=sashelp.air;
run;
ods pdf close;
Look at the startpage option on the ODS PDF statement and go through the examples.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.