BookmarkSubscribeRSS Feed
PhilMason
Obsidian | Level 7
I am trying to replace a complex EXCEL report by producing the report using ODS PDF. We are using SAS 9.1.3 which means we have less functionality available than in SAS 9.2. The report I am trying to make has a range of tables & graphs in different positions on the page. I have worked out how to do quite a lot using ODS Layout, but I have some problems.

(1) Is there a way to control the individual borders for a cell? For example, I would like most of the borders on in one table, but the top left cell I want its top & left borders off.

(2) Is there a way to merge cells? In EXCEL I can make a table and then perhaps merge 2 of the cells - this is what I want to do.

(3) Is there a way to fit text to a cell of fixed size? Another thing that can be done in EXCEL that I would like to reproduce so that when a cell has very long text it will still fit.

I had also tried using ODS data step objects, but these are a bit limited in 9.1.3 too. I would really appreciate some help or to know whether this is just not possible in 9.1.3. If we can do this in SAS with ODS then we think we can speed up transactions in a web application which produces output in EXCEL using vbScript.

thanks
Phil Mason
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi, Phil:
You might want to check with Tech Support for the definitive answer, but my take on your questions is:

1) individual borders -- this was an enhancement for SAS 9.2 -- there are now borderleftmargin, borderleftstyle, borderleftwidth and borderleftcolor attributes (and also for top, bottom, right) that have an impact on output. I remember that they work all work, but work slightly differently for RTF, PDF and HTML. I believe that some individual border control was possible with HTML using CSS style properties and with RTF using RTF control strings in 9.1.3 -- nothing for PDF, however.

2) Not sure WHAT cells you want to merge. Again, in 9.2, with PROC REPORT, row spanning is possible with the SPANROWS option. but if, for example, you had SASHELP.CLASS and wanted to merge the column for NAME with the column for AGE, then you would have to concatenate the 2 values together in a data step program prior to using the values on your report. There is no equivalent to merging 2 columns that I know of.

3) When you say "fit text to a cell of a fixed size", it sounds to me like you want to wrap text in a cell. I can do this easily using the cellwidth option in PDF -- you get wrapping for free. See the example below.

I don't use the DATA step object very much these days because it is still being enhanced and could change between now and when it becomes production. I wouldn't expect that it would be productive. However, these papers do have some good info on using ODS LAYOUT and I believe that at least one of them was using SAS and 9.1.3:
http://www2.sas.com/proceedings/sugi31/092-31.pdf
http://biostatistics.kumc.edu/docs/journalclub/Journal2009Novemberpt2.pdf
http://vasug.files.wordpress.com/2009/06/ods-layout.pdf
http://www.wuss.org/proceedings09/09WUSSProceedings/papers/dpr/DPR-OConnor.pdf
http://support.sas.com/resources/papers/proceedings10/232-2010.pdf
http://www2.sas.com/proceedings/sugi28/022-28.pdf

Without seeing what you are actually trying to produce, it is hard to comment on whether it's possible with 9.1.3 -- you might want to check with Tech Support to get some determination on the question.

cynthia
[pre]
title; footnote;
options linesize=180;
data testit;
length nameage $20;
set sashelp.class;
charvar = '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.';
nameage = catx('~~',name,put(age,2.0));
output;
run;

ods listing;
ods html file='c:\temp\wrap.html' style=egdefault;
ods rtf file='c:\temp\wrap.rtf';
ods pdf file='c:\temp\wrap2.pdf';
ods escapechar='~';
** note that charvar3 has an explicit line feed for
RTF, PDF and HTML: ~n;

proc print data=testit;
title 'Proc Print';
title2 ' LISTING will not use cellwidth; format of $20 will truncate value';
where age gt 14;
var charvar / style(data)={cellwidth=1in};
var charvar2 charvar3 name age nameage;
format charvar2 $20.;
run;

proc report data=testit nowd;
where age gt 14;
title 'Proc Report';
title2 'Listing will use FLOW, other Destinations will use cellwidth';
column ("Note wrapping" charvar charvar2 charvar3) ("Note NAMEAGE var" name age nameage);
define charvar / style(column)={cellwidth=1in};
define charvar2/ flow width=20;
define charvar3 / display;
define name/ display;
run;
ods _all_ close;
[/pre]

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 883 views
  • 0 likes
  • 2 in conversation