BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
nishant77goel
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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:

  • PROC ODS TEXT - for text comments and/or title page (hardest part)
  • ODS LAYOUT and controlling the position of your text/output (hardest part)
  • ODS PDF (simplest thing here most likely)
  • ODS PDF + Table of Contents (fairly easy)
  • PROC REPORT for traffic lighting/reporting customization (medium complexity)

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.


 

View solution in original post

3 REPLIES 3
Reeza
Super User

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:

  • PROC ODS TEXT - for text comments and/or title page (hardest part)
  • ODS LAYOUT and controlling the position of your text/output (hardest part)
  • ODS PDF (simplest thing here most likely)
  • ODS PDF + Table of Contents (fairly easy)
  • PROC REPORT for traffic lighting/reporting customization (medium complexity)

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.


 

nishant77goel
Obsidian | Level 7
Hi Reeza, thanks for providing the detailed explanation. Surely it is going to help me a lot.
One thing more I want to know is how create and concatenate different pages like the cover page, contents page and tables in single PDF. I hope this will help me in understanding and building an overall picture for this automation. If you have any example where you are creating PDF with multiple pages will surely be helpful.

Thank You!
Reeza
Super User

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. 

https://documentation.sas.com/?docsetId=odsug&docsetTarget=n0mc4eolqoned0n16oy88mpj0e4g.htm&docsetVe...

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 597 views
  • 2 likes
  • 2 in conversation