BookmarkSubscribeRSS Feed
GregINGov
Calcite | Level 5


Hi all, I have an ODS PDF report, and it stops wrapping my vendor name, in the middle of the report and when that happens it causes the report to move two columns to a next page.

(Cynthia you helped me design this report a few years ago because I needed help getting the data to go both vertical and horizontal)

can I force this line to word wrap at so many letters?  if so how or do you need to see another part of my code?

 

define vnames / display 'Vendors' left;

Greg

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:

  I searched for your previous post and didn't find it. More than a single DEFINE statement is needed, to figure things out, however. It doesn't look like you used cellwidth in this DEFINE statement -- one way to control a report that is pushing a few columns to another page is to set OUTPUTWIDTH=100% or WIDTH=100% to see if that shrinks the columns as needed. Another thing to do is to adjust the fonts used for the report, so they are slightly smaller and/or change the margins. Or, you can try to explicitly control the cellwidth of all the columns. I don't see any of that in your DEFINE statement. You don't say whether your output is portrait or landscape, I'd guess landscape, if it's very wide.

  In order to debug this, it's going to be necessary for you to know what system options are in effect, since ODS PDF can be impacted by the system margin settings and orientation setting.

  Some changes you could try are:

options orientation=landscape leftmargin=.25in rightmargin=.25in

         topmargin=.25in bottommargin=.25in;

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

proc report data=xxx.yyy nowd

     style(report)={font_size=9pt outputwidth=100%}

     style(column)={font_size=9pt}

     style(header)={font_size=10pt fontweight=bold};

... rest of code ...

ods pdf close;

But without seeing more of your code and seeing a sample of your data, it's hard to make a more concrete suggestion. For a very wide report, if I helped you with the code, it's odd that I didn't recommend any style= options. Although, it's possible that in an earlier version of SAS, everything fit with just a simple change to landscape or a margin change.

I don't understand exactly what you mean by "stops wrapping vendor name" -- usually, you can force wrapping to happen in a cell when you make the cellwidth smaller than the string needs to fit on one line. I don't see any cellwidth adjustment in your DEFINE statement, so any wrapping that you got in the past was probably coincidental.

You can code an explicit "line feed" character to force a break in a string. Consider the program below and notice how the break happens in CHARVAR3 and CHARVAR4, using ODS ESCAPECHAR. Note how CHARVAR1 wraps differently with an explicit cellwidth versus using outputwidth (in report #3).

If you can't post all your code and a sample of your data, then you might want to work with Tech Support, since they can look at all your code and your data and help you figure out how to get your value to wrap. There were some font rendering and other changes between 9.1.3 and 9.2 and between 9.2 and 9.3 that might be coming into play. Did you recently upgrade?  Did you change the job submission method -- like using EG? These papers and notes might help,

http://support.sas.com/resources/papers/proceedings10/035-2010.pdf

http://support.sas.com/resources/papers/proceedings12/260-2012.pdf

http://support.sas.com/kb/4/781.html

http://support.sas.com/kb/10/851.html

in addition to trying some of the techniques shown in the program below.

cynthia

data testit;
  length charvar1 charvar2 charvar3 $200 charvar4 $600;
  set sashelp.class;
  where name in ('Alfred', 'Barbara');
  charvar1 = 'Twas brillig and the slithy toves did gyre and gimble in the wabe.';
  charvar2 = 'All mimsy were the borogroves and the mome raths outgrabe.';
  charvar3 = 'Beware the Jabberwock, my son!~nThe jaws that bite, the claws that snatch.';
  charvar4 = catx('~n',charvar1,charvar2,charvar3);
  output;
run;

   

options orientation=landscape topmargin=.25in bottommargin=.25in
        leftmargin=.25in rightmargin=.25in;
ods listing close;

  
ods pdf file='c:\temp\wrap.pdf';
ods escapechar='~';
** note that charvar3 and charvar4 have 
   explicit line feed characters
   using ODS ESCAPECHAR+n or ~n
   for RTF, PDF and HTML.
   In 9.3 can use ~{newline 1} instead of ~n;

   

proc print data=testit;
  title 'Proc Print';
  var charvar1 / style(data)={cellwidth=.75in};
  var charvar2 /style(data)={cellwidth=1.5in};
  var charvar3 / style(data)={cellwidth=3in};
  var charvar4 / style(data)={cellwidth=4in};
  var name;
run;
   
proc report data=testit nowd;
  title 'Proc Report #1';
  column charvar1 charvar2 charvar3 charvar4 name;
  define charvar1 / display style(column)={cellwidth=.75in};
  define charvar2/ display style(column)={cellwidth=1.5in};
  define charvar3 / display  style(column)={cellwidth=3in};
  define charvar4 / display style(column)={cellwidth=4in};
  define name/ display;
run;
    
proc report data=testit nowd
     style(report)={outputwidth=100% font_size=10pt}
     style(header)={font_size=10pt}
     style(column)={font_size=9pt};
  title 'Proc Report #2';
  column charvar1 charvar2 charvar3 charvar4 name;
  define charvar1 / display ;
  define charvar2/ display ;
  define charvar3 / display ;
  define charvar4 / display ;
  define name/ display;
run;
ods _all_ close;

GregINGov
Calcite | Level 5

Cynthia,

My report is portrait

Because  you help me...you put in a lot of style into my report(guess I am lost in all style)....but I tried changing the font sizes ...for some reason it did affect the report.....

You ask, "I don't understand exactly what you mean by "stops wrapping vendor name"...I wish I could show the report but can not because of the data....yeah the strange thing was the vendor would wrap where all columns

were displaying on same page....but when it went to a second page the vendor name would display on one line..................

what I decided the problem was my item description was 40

this line almost to the bottom:

line 'Proposal:' iplineno $20. ' Item: ' item $13. ' ' idescr $40. ' Units: ' iunits $4. ' Median Price: ' mediancost dollar15.2;

so as a fix now,...... I change....... idescr $40 from 40 to 25 ....and that allow everything to print on one page if there is a way for  me to

leave idescr at $40 by changing something I am showing below let  me know and I will give it a try.

Thanks for all your help....and I  thank you again for when you helped me long ago on this report!

Your one of the best!  Smiley Happy

 

** make a style template to do the cyan title;

** need black box around title ONLY;

** need to set frame=void for table;

** want frame=box for systitleandfooter container;

** this is a copy of styles.printer, but with;

** changes for cyan title and trying for black box;

** around title. Also made some font changes;

proc template;

define style Styles.specstyl;

parent = styles.default;

replace fonts /

'TitleFont2' = ("Times Roman",11pt,Bold Italic)

'TitleFont' = ("Times Roman",11pt,Bold Italic)

'StrongFont' = ("Times Roman",10pt,Bold)

'EmphasisFont' = ("Times Roman",10pt,Italic)

'FixedEmphasisFont' = ("Courier",9pt,Italic)

'FixedStrongFont' = ("Courier",9pt,Bold)

'FixedHeadingFont' = ("Courier",9pt,Bold)

'BatchFixedFont' = ("SAS Monospace, Courier",6.7pt)

'FixedFont' = ("Courier",9pt)

'headingEmphasisFont' = ("Times Roman",11pt,Bold Italic)

'headingFont' = ("Times Roman",11pt,Bold)

'docFont' = ("Times Roman",9pt);

replace GraphFonts /

'GraphDataFont' = ("Times Roman",8pt)

'GraphValueFont' = ("Times Roman",10pt)

'GraphLabelFont' = ("Times Roman",12pt,Bold)

'GraphFootnoteFont' = ("Times Roman",12pt,Bold)

'GraphTitleFont' = ("Times Roman",14pt,Bold);

replace Table from Output /

rules = NONE

frame = VOID

cellpadding = 3

cellspacing = 0;

replace color_list

"Colors used in the default style" /

'link' = blue

'bgH' = grayBB

'fg' = black

'bg' = _undef_;

replace Body from Document

"margins will come from printer or SYS option" /

bottommargin = _undef_

topmargin = _undef_

rightmargin = _undef_

leftmargin = _undef_

pagebreakhtml = html('PageBreakLine');

replace colors

"Abstract colors used in the default style" /

'headerfgemph' = color_list('fg')

'headerbgemph' = color_list('bgH')

'headerfgstrong' = color_list('fg')

'headerbgstrong' = color_list('bgH')

'headerfg' = color_list('fg')

'headerbg' = color_list('bgH')

'datafgemph' = color_list('fg')

'databgemph' = color_list('bg')

'datafgstrong' = color_list('fg')

'databgstrong' = color_list('bg')

'datafg' = color_list('fg')

'databg' = color_list('bg')

'batchbg' = color_list('bg')

'batchfg' = color_list('fg')

'tableborder' = color_list('fg')

'tablebg' = color_list('bg')

'notefg' = color_list('fg')

'notebg' = color_list('bg')

'bylinefg' = color_list('fg')

'bylinebg' = color_list('bg')

'captionfg' = color_list('fg')

'captionbg' = color_list('bg')

'proctitlefg' = color_list('fg')

'proctitlebg' = color_list('bg')

'titlefg' = color_list('fg')

'titlebg' = color_list('bg')

'systitlefg' = color_list('fg')

'systitlebg' = color_list('bg')

'Conentryfg' = color_list('fg')

'Confolderfg' = color_list('fg')

'Contitlefg' = color_list('fg')

'link2' = color_list('link')

'link1' = color_list('link')

'contentfg' = color_list('fg')

'contentbg' = color_list('bg')

'docfg' = color_list('fg')

'docbg' = color_list('bg');

replace GraphColors /

'gcerror' = cx000000

'gerror' = cxA0A0A0

'gcpredictlim' = cx000000

'gpredictlim' = cxC8C8C8

'gcpredict' = cx000000

'gpredict' = cx000000

'gcconfidence' = cx000000

'gconfidence' = cxC8C8C8

'gcfit' = cx000000

'gfit' = cx000000

'gcoutlier' = cx000000

'goutlier' = cxA0A0A0

'gcdata' = cx000000

'gdata' = cxA0A0A0

'ginsetheader' = colors('docbg')

'ginset' = cxFFFFFF

'greferencelines' = cxCDCDCD

'gheader' = colors('docbg')

'gconramp3cend' = cx5F5F5F

'gconramp3cneutral' = cxA7A7A7

'gconramp3cstart' = cxF0F0F0

'gramp3cend' = cx5F5F5F

'gramp3cneutral' = cxA7A7A7

'gramp3cstart' = cxF0F0F0

'gconramp2cend' = cx5F5F5F

'gconramp2cstart' = cxF0F0F0

'gramp2cend' = cx5F5F5F

'gramp2cstart' = cxF0F0F0

'gtext' = cx000000

'glabel' = cx000000

'gborderlines' = cx000000

'goutlines' = cx000000

'ggrid' = cxECECEC

'gaxis' = cx000000

'gshadow' = cx000000

'glegend' = cxFFFFFF

'gfloor' = cxCCCCCC

'gwalls' = cxFFFFFF

'gcdata12' = cx000000

'gcdata11' = cx000000

'gcdata10' = cx000000

'gcdata9' = cx000000

'gcdata8' = cx000000

'gcdata7' = cx000000

'gcdata6' = cx000000

'gcdata5' = cx000000

'gcdata4' = cx000000

'gcdata3' = cx000000

'gcdata2' = cx000000

'gcdata1' = cx000000

'gdata12' = CX2F2F2F

'gdata11' = CX6F6F6F

'gdata10' = CXCFCFCF

'gdata9' = CX8F8F8F

'gdata8' = CX4F4F4F

'gdata7' = CXAFAFAF

'gdata6' = CX0F0F0F

'gdata5' = CX7F7F7F

'gdata4' = CX3F3F3F

'gdata3' = CX9F9F9F

'gdata2' = CX5F5F5F

'gdata1' = CXBFBFBF;

replace Container

"Abstract." /

font = Fonts('DocFont')

foreground = colors('docfg')

background = colors('docbg');

style ContentTitle from IndexTitle

"Controls the title of the Contents file." /

fillrulewidth = 0.5pt

rightmargin = 1em

leftmargin = 1em

outputwidth = 100%

bottommargin = 4ex

topmargin = 3ex

font = fonts('TitleFont')

pretext = text('content title')

just = C;

replace PrintedContentsLabel

"Sort of a post-posttext for the CONTENTS" /

posttext = " (*ESC*){leaders . }(*ESC*){tocentrypage}"

pretext = "(*ESC*){tocentryindent 2em}";

replace ContentItem from IndexItem

"Controls the leafnode item in the Contents file." /

rightmargin = 15%

leftmargin = 15%

just = L;

replace ContentFolder from IndexItem

"Controls the generic folder definition in the Contents file." /

rightmargin = 15%

leftmargin = 15%

just = L

listentryanchor = off

foreground = colors('confolderfg');

replace ContentProcName from IndexProcName

"Controls the proc name in the Contents file." /

rightmargin = 15%

leftmargin = 15%

just = L;

replace ContentProcLabel from ContentProcName

"Controls the proc label in the Contents file." /

posttext = _undef_

pretext = _undef_;

replace Date from Container

"Abstract. Controls how date fields look." /

outputwidth = _undef_

background = colors('contentbg')

foreground = colors('contentfg');

replace SysTitleAndFooterContainer from Container

"Changed container" /

background = #66ffcc

foreground = black

rules = NONE

frame = Box

outputwidth = 100%

cellpadding = 3

cellspacing = 0

borderwidth = 3

bordercolor=black;

replace TitleAndNoteContainer from Container

"Changed container" /

background = #66ffcc

foreground = black

rules = NONE

frame = Box

outputwidth = 100%

cellpadding = 3

cellspacing = 0

borderwidth = 3

bordercolor=black;

replace TitlesAndFooters from Container

"Changed container" /

background = #66ffcc

foreground = black

rules=NONE

frame=box

outputwidth=100%

cellpadding=3

cellspacing=0

borderwidth=3

bordercolor=black;

replace SystemTitle from TitlesAndFooters

"Controls system title text." /

font = Fonts('TitleFont')

background=#66ffcc;

replace SystemFooter from TitlesAndFooters

"Controls system footer text." /

font = Fonts('TitleFont')

background=#66ffcc;

end;

run;

** start ods pdf and close listing;

 

** use style template from above;

ods listing close;

** Name the pdf and the location of the file;

ods pdf file ="&jobdir.bidreportJ.pdf";

** will need ods escapechar for the title;

ods escapechar='~';

** use proc report style= overrides to make report changes;

** rules= none turns off interior table lines;

** frame= void turns off box around table;

** cellspacing= 0 turns off the space between each cell;

** cellpadding=3 minimizes the white space -inside- each cell;

** background= changes background color of cell;

** default for header cell is gray;

** foreground= changes foreground color of cell;

** just= l changes justification in a table cell;

** note, cannot do underline in PDF for under column;

** headers without making something like a row of dashes;

** which does not look very good ;

** ~{thispage} is the PDF way to get page numbers onto;

** the report and ~n is the way to get a forced line break;

** after the word "Indiana" and ~_ is a non-breaking space;

 

options linesize=256;

proc report data=fixest nowd

style(report)={rules=none frame=void

cellspacing=0 cellpadding=3

just=l}

style(header)={background=white just=c};

title1 j=l 'Letting Date: #byval(cndtlet)'

j=r 'Page: ~{thispage}';

title2 j=l " "

j=c 'Greg~nplace~_of~_work';

title3 j=l ' '

j=c 'Unbalanced~_Bid~_Report';

title4 j=l ' '

j=c "%sysfunc(today() ,worddate18.)";

title5 j=l 'Lowest Bidder: #byval(lvenname) '

j=r 'Contract Number: #byval(contid)';

title6 j=l 'Lowest Bid Amount: #byval(newlowest)'

j=r 'Greg  Amount: #byval(newest)';

by descending cndtlet contid newest newlowest lvenname;

format cndtlet worddate18.;

column cndtlet iplineno item idescr iunits mediancost

vnames btoqty btuprice btextamt Balflag;

define cndtlet / group descending noprint;

define iplineno / group noprint;

define item / group noprint;

define idescr / group noprint;

define iunits / group noprint;

define mediancost / group noprint;

define vnames / display 'Vendors' left;

define btoqty / display 'Quantity' center;

define btuprice / display 'UBP' center f=dollar14.2 width =16;

define btextamt / display 'Amount' center width =12;

define Balflag / display 'Flag' center width =4;

compute Balflag / character length=1;

if balflag = 'U' then do;

call define(_ROW_,'STYLE','style={background=yellow}');

end;

if balflag = 'A' then do;

call define(_ROW_,'STYLE','style={background=orange}');

end;

if balflag = 'F' then do;

call define(_ROW_,'STYLE','style={background=red}');

end;

endcomp;

break after cndtlet / ;

compute after cndtlet;

line @ 1 "Note: UBP is the Vendor's unit bid price. Median Price is the median of the UBP of each proposal line. If Flagged as 'U' and";

line "yellow, this is a bid of less than %60 of the median price. If Flagged as 'A' and orange, this is a bid of greater than %60 of";

line "the median price. And if Flagged as 'F' and red, this is a bid greater than %60 of the median price and is a front loaded item.";

endcomp;

** next compute block does the gray bar;

** underneath the header and at the start of every ;

** iplineno. If some of this info is going to come;

** from macro vars will need double quotes and if;

** some of this info is coming from data, will need;

** to change column statement to include those vars;

compute before mediancost /

style={background=#cccccc just=l};

line 'Proposal:' iplineno $20. ' Item: ' item $13. ' ' idescr $40. ' Units: ' iunits $4. ' Median Price: ' mediancost dollar15.2;

endcomp;

** this compute block skips a line after every iplineno;

compute after mediancost;

line ' ';

endcomp;

run;

ods listing close;

Cynthia_sas
SAS Super FREQ

Hi:

  That was a long time ago -- back in 2005, right? As I remember, you wanted a cyan or green background around the title with a big black outline around the titles...or something like that.

  That is an old style template -- the REPLACE statement went away in SAS 9.2, that should not cause a problem here. I think that your LINE statement probably forced the inserted line to be wider than could be accomodated by the margins that were in force. One thing that you can do is to change the font_size:

compute before mediancost /

     style={background=#cccccc just=l font_size=8pt};

   line 'Proposal:' iplineno $20. ' Item: ' item $13. ' ' idescr $40.

        ' Units: ' iunits $4. ' Median Price: ' mediancost dollar15.2;

endcomp;

Otherrwise, you might want to open a track with Tech Support to see if there's anything else that could be impacting your output other than margins and size of the constructed LINE string.

cynthia

GregINGov
Calcite | Level 5

Cynthia,

wow, I guess I foregot how long ago it was too, at least 2005 !

Thanks for the additional suggestions!

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
  • 1388 views
  • 0 likes
  • 2 in conversation