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

Hi all,

I need short help with the proc report that exported into PDF file.

So,SAS table, that is source for proc report has ,for example, 10 columns.

First 3 columns should has constant width, it can be simply set by cellwidth option, its clear.

Rest 7 columns contains of character that can have different length(1,100,1000 etc.).

Don't set columns width isn't ok becouse if column has long value all report splits into two different in PDF(few first column in first report rest in second, below first).

Set manually column width is also not so good, becouse in target pdf report will be many reports(created in loop) with same structture but different data, so as result can be situation when we all columns except one is empty , one has long value but they all have same width.

So in general report should fit into one landscape page(~10.4in) plus last 7 rows should have logicall width, depends on maximum(or avarage) column value length.

For exampe::

If one column has three times longer value than all another column - this column should be three times bigger then all these another columns.

In another word, I wont set manually column width for few columns, and the rest columns should use rest size of landscape page as logicall as possible, but not cross left page border.

Looks like can be enougth to set smth. like max report width, but I don't see such option for whole report, just for columns...

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  Well, you can always introduce an ESCAPECHAR function {newline} into your long text strings if you need to break them at a particular place to make them more readable. Look at the difference between the extra space that's been added to the REALLY_LONG variable versus the R_R_LONG or RRRRLONG variables.

cynthia

data class(keep=name really_long r_r_long rrrrlong);
  length long $35 temp really_long $275 r_r_long $1000
         rrrrlong $4000;
  set sashelp.class;
  where age ge 15;
  long = 'supercalifragilisticexpialidocious';
  temp = catx(' ','Twas brillig and the slithy toves',
         'Did gyre and gimble in the wabe.',
         'All mimsy were the borogoroves,',
         'And the mome raths outgrabe.');
 
  ** add explicit line break into REALLY_LONG variable, but not in others;
  really_long = catx('^{newline 3}',temp,temp);
  r_r_long = catx(' ',temp,temp,long,temp,temp);
  rrrrlong=catx(' ',r_r_long,r_r_long,long,r_r_long,r_r_long);
run;
  
ods listing close;
options orientation=landscape nodate
        nonumber
        topmargin=.25in bottommargin=.25in
        leftmargin=.25in rightmargin=.25in;
          
ods escapechar='^';
ODS pdf file="c:\temp\reallylong.pdf" ;
PROC report data=class nowd;
  column name really_long r_r_long rrrrlong;
  define name / display
         style(column)={width=.75in};
  define really_long / display
         style(column)={width=2.25in};
  define r_r_long/ display
         style(column)={width=3.5in};
  define rrrrlong / display
         style(column)={width=3.5in};
run;

ODS pdf close;

View solution in original post

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:

  There is an option to set the output width of the whole report. PDF is generally happier if you let it calculate the cellwidths that it needs.

  However, for your scenario, if your first 3 columns must always be a fixed width, while the other columns change size dynamically based on the contents of the column, then that is an argument for a combination of changes at the STYLE(REPORT) level and the STYLE(COLUMN)/STYLE(HEADER) level.

  Without seeing your code and your data and how it dynamically changes from report to report, it is difficult to provide much help. You might want to work with Tech Support on this question. They can look at ALL your code and your DATA and make some concrete suggestions.

  I've pasted a program below that just illustrates changing the outputwidth of the entire report, based on a percentage of the size or actual size in inches (based on margins of .25 all around, that gives 11in - .5in = 10.5 in.

   My tendency is not to "over-control" the widths when I use PDF -- it has its own calculations that it does based on margins, papersize, fontsize, text string length, etc. I generally change the STYLE(REPORT) and make margin and font changes or I change the width of the individual columns, but I don't do both. But again, for the most specific help, you might want to work with Tech Support.

cynthia

options orientation=landscape nodate

        nonumber

        topmargin=.25in bottommargin=.25in

        leftmargin=.25in rightmargin=.25in;

ods listing close;

title; footnote;

  

ods pdf file='c:\temp\width75_100.pdf';

  proc report data=sashelp.class nowd

       style(report)={outputwidth=75%};

  title '1) Outputwidth 75%';

  run;

  

  proc report data=sashelp.class nowd

       style(report)={outputwidth=100%};

  title '2) Outputwidth 100%';

  run;

  

  proc report data=sashelp.class nowd

       style(report)={outputwidth=10.5in};

  title '3) Outputwidth 10.5in';

  run;

  

ods pdf close;

Yura2301
Quartz | Level 8

Hi Cynthia,

I see your point, I also tried before option that you described in your example(outputwidth etc.),but the root of problem is that if I'll not assign column width in proc report for each column, this width will be automatically defined by ODS pdf engine ,based on margins, papersize, fontsize as you described, and if few columns has values with long chars one row of data splits into two that is absolutelly unreadible.

For now I just set column width for each column(cellwidth statement) but sometimes it's also not the best variant becouse as I described higher - I can't predict len. of columns,so , for example, if I set for all of them same length,-  in one report all cols can has similar length - in this case all is ok, but in another report(with same set of columns but diff data) one column can has long string and another is just empty, so logically will be make this one column wider than another one.
As I know in HTML tables exits possibility limit whole HTML table size and column width automatically defines from HTML tables cell content(just len of value in cell), and proc report in the end ganarates HTML table, so I supposed that should exist option that can limit whole proc report width, so even if all columns will have long char - each row will not be splitted into two, it will be just very high and it width will be some logicall depended from margins, papersize, fontsize values length of another columns etc.

But ok, looks like I spend too much time on this small issue:)

Thanks!

Cynthia_sas
SAS Super FREQ

Hi:

  Well, you can always introduce an ESCAPECHAR function {newline} into your long text strings if you need to break them at a particular place to make them more readable. Look at the difference between the extra space that's been added to the REALLY_LONG variable versus the R_R_LONG or RRRRLONG variables.

cynthia

data class(keep=name really_long r_r_long rrrrlong);
  length long $35 temp really_long $275 r_r_long $1000
         rrrrlong $4000;
  set sashelp.class;
  where age ge 15;
  long = 'supercalifragilisticexpialidocious';
  temp = catx(' ','Twas brillig and the slithy toves',
         'Did gyre and gimble in the wabe.',
         'All mimsy were the borogoroves,',
         'And the mome raths outgrabe.');
 
  ** add explicit line break into REALLY_LONG variable, but not in others;
  really_long = catx('^{newline 3}',temp,temp);
  r_r_long = catx(' ',temp,temp,long,temp,temp);
  rrrrlong=catx(' ',r_r_long,r_r_long,long,r_r_long,r_r_long);
run;
  
ods listing close;
options orientation=landscape nodate
        nonumber
        topmargin=.25in bottommargin=.25in
        leftmargin=.25in rightmargin=.25in;
          
ods escapechar='^';
ODS pdf file="c:\temp\reallylong.pdf" ;
PROC report data=class nowd;
  column name really_long r_r_long rrrrlong;
  define name / display
         style(column)={width=.75in};
  define really_long / display
         style(column)={width=2.25in};
  define r_r_long/ display
         style(column)={width=3.5in};
  define rrrrlong / display
         style(column)={width=3.5in};
run;

ODS pdf close;

Yura2301
Quartz | Level 8

Hi Cynthia,

It's probably what I need:), thanks!
I'll just check how it will influance on performance and if it will be acceptable - I'll use this ESCAPECHAR function to achive needed format view.

Thanks once more!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 4 replies
  • 14964 views
  • 0 likes
  • 2 in conversation