Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get rid of horizontal lines in ODS RTF

Status
Not open for further replies.

khfor2007

IS-IT--Management
Mar 13, 2007
9
US
Hi everyone,

I am using STYLE=RTF in the following program and encounter a problem: I need to get rid of the horizontal lines (not all) every time the variable NAME changes the value(in this case it goes from FACID to LTYPE).

Here is my code:

Code:
data test;
  infile datalines dsd;
  input name $ type $ len $ desc $ ;
datalines;
facid,char,3,oak
, , ,fre
, , ,rch
ltype,char,1,kfh
;
run;
ods listing close;
ods rtf 
   file  ='c:\temp\test1.rtf'
   style =rtf
   rs    =none ;
proc print data=test noobs;
run;
ods rtf close;

Any help would be greatly appreciated!

 
OK. Not exactly sure this will help, but should put you on the right course I hope.
You can amend the style using proc template. This in itself sounds a little complex, however, you can also use Proc Template to extract the code required to make the template in the first place, so that gives you a good start point.
Code:
proc template;
  source styles.rtf;
run;
quit;
If you run this, then look in your log, you'll see a define statement which defines the RTF style. You can then paste this into another proc template step to create a new style (I recommend using a new name rather than overwriting the original to avoid any issues if you break it).
If the style elements listed in the define statement don't seem to help, then look to the PARENT. In this case the parent is "STYLES.PRINTER" so you run a SOURCE statement for THAT and see if any of THOSE style elements will help. You can then combine both sets of SOURCE into 1 DEFINE statement, dropping out style elements from PRINTER that are superseded in RTF. You may even even need to go to the parent of PRINTER (DEFAULT) to make the changes necessary.
If you need help on the style elements, post back here, but there's also a chunk of documentation on PROC TEMPLATE on the SAS Support website that might help, though I've tended to find that the doco is a little lacking in specifics.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Thank you for your help,Chris.
I have read some papers on Proc Template and actually modified the PARENT style to get rid of the lines as the following code
Code:
PROC TEMPLATE ;                                                      
    DEFINE STYLE SMALLFONTS;                                           
    PARENT=STYLES.minimal  ;                                           
    REPLACE FONTS /                                                    
     'TitleFont2'          = ("Arial",1,Bold Italic)                   
     'TitleFont'           = ("Arial",1,BoLD)  /*title from proc*/     
     'StrongFont'          = ("Arial",2)                               
     'EmphasisFont'        = ("Arial" ,1,Italic)                       
     'FixedEmphasisFont'   = ("Arial",1,Italic)                        
     'FixedStrongFont'     = ("Arial",1 )                              
     'FixedHeadingFont'    = ("Arial",1)                               
     'BatchFixedFont'      = ("SAS Monospace",1)                       
     'FixedFont'           = ("Courier",1)                             
     'headingEmphasisFont' = ("Arial",1,Bold Italic)                   
     'HEADINGFONT'         = ("ARIAL",1,BOLD)  /*header*/              
     'docFont'             = ("Arial",1);                              
    replace colors /                                                   
     'bgH' = white                 /*header background           */    
     'fg'  = black                 /*foreground                  */    
     'bg'  = _undef_;              /*background _under_ =flexible*/    
                                                                       
    REPLACE OUTPUT FROM CONTAINER /                                    
     Background =colors('tablebg')                                     
     Rules      =none    /*internal border:none all cols rows group*/  
     frame      =void    /*outsider border:void box vsides hsides*/    
     cellpadding=5                                                     
     cellspacing=0                                                     
     ;                                                                 
  END;                                                                 
 RUN;    
[code/]
Note that using RULE=NONE  will remove all lines but that is not exactly what I want...
I will look into the whole RTF code as you suggest and see if I could make any change. Thank you for your suggestions.
 
So, do you want to leave a line when the variable NAME changes, but not for other records?
You might want to try Proc Report instead of Proc Print, you can do some funky things with that. For instance...
Code:
proc report data=transactors nowd;
  columns bsb count1 percent1 count2 percent2 count3 percent3 totcus groupvar;

  define bsb  /order 'Transacting Branch';
  define count1   /sum 'Count of customers using as Primary Branch';
  define percent1 /sum 'Percentage of Customers';

  define count2   /sum 'Count of customers using as Secondary Branch';
  define percent2 /sum 'Percentage of Customers';

  define count3   /sum 'Count of customers using as Tertiary Branch';
  define percent3 /sum 'Percentage of Customers';

  define totcus /sum computed 'Total Customers';

   define groupvar     /noprint;

   compute totcus /;
     totcus = sum(count1.sum,count2.sum,count3.sum);
   endcomp;

   compute groupvar /character length=40;

       * Initialise colr flag variable for first run *;
       if colr = < 0.5 then
       do;
         colr = 1;
         CALL DEFINE(_ROW_, "STYLE",
                     "STYLE=[BACKGROUND=cxFFFFFF]");
       end;
       else
       do;
           if BSB ne groupvar then
           do;
               if round(colr) = 1 then
               do;
                   colr = 2;
                   CALL DEFINE(_ROW_, "STYLE",
                              "STYLE=[BACKGROUND=cxDFD8C3]");
               end;
               else if round(colr) = 2 then
               do;
                   colr = 1;
                   CALL DEFINE(_ROW_, "STYLE",
                                "STYLE=[BACKGROUND=cxFFFFFF]");
               end;
           end;
           else
           do;
               if round(colr) = 1 then
               do;
                    CALL DEFINE(_ROW_, "STYLE",
                              "STYLE=[BACKGROUND=cxFFFFFF]");

               end;
               else if round(colr) = 2 then
               do;
                    CALL DEFINE(_ROW_, "STYLE",
                               "STYLE=[BACKGROUND=cxDFD8C3]");
               end;
           end;
       end;
       groupvar = BSB;
    endcomp;

    rbreak after /summarize;

run;

Change "BSB" in the compute section to NAME, and try that. It should colour the first NAME records grey, then for the next value of NAME become white, then grey again and so on.
There's options for adding in underlining in proc report as well which might help...

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Actually, I'm not sure how it works with RTF. I usually use it with tagsets.excelXP which produces an Excel Spreadsheet.
This is a more portable version of the example, you can run this on any SAS machine without setting up anything. Providing you have SAS version 9.
Code:
ods tagsets.excelxp file="c:\groups.xls"
    options(absolute_column_width='10,10,10,10,8,8,8,8,8,8,8,8,8,8'
            row_repeat='header'
            embedded_titles='yes'
            frozen_headers='yes'
            scale='100' 
            orientation='landscape'
            sheet_name='Report'
           )
   ;

proc report data=sashelp.class nowd;
  columns sex name  age height weight BMI  groupvar;

  define sex  /order 'Gender';
  define name /order 'Name';
  define age   /sum 'Age';
  define height /sum 'Height (inches)' format=8.1;
  define weight   /sum 'Weight (lbs)' format=8.1;
  define BMI /computed 'BMI'  format=8.2;

  define groupvar     /noprint;

   compute BMI /;
     BMI = 703*weight.sum/(height.sum * height.sum);
   endcomp;

   compute groupvar /character length=40;

       * Initialise colr flag variable for first run *;
       if colr = < 0.5 then
       do;
         colr = 1;
         CALL DEFINE(_ROW_, "STYLE",
                     "STYLE=[BACKGROUND=cxFFFFFF]");
       end;
       else
       do;
           if sex ne groupvar then
           do;
               if round(colr) = 1 then
               do;
                   colr = 2;
                   CALL DEFINE(_ROW_, "STYLE",
                              "STYLE=[BACKGROUND=cxDFD8C3]");
               end;
               else if round(colr) = 2 then
               do;
                   colr = 1;
                   CALL DEFINE(_ROW_, "STYLE",
                                "STYLE=[BACKGROUND=cxFFFFFF]");
               end;
           end;
           else
           do;
               if round(colr) = 1 then
               do;
                    CALL DEFINE(_ROW_, "STYLE",
                              "STYLE=[BACKGROUND=cxFFFFFF]");

               end;
               else if round(colr) = 2 then
               do;
                    CALL DEFINE(_ROW_, "STYLE",
                               "STYLE=[BACKGROUND=cxDFD8C3]");
               end;
           end;
       end;
       groupvar = sex;
    endcomp;

    rbreak after /summarize;

run;

ods tagsets.excelxp close;

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Ooooh, it does work , and looks pretty good too. I changed the ODS tagsets.... part to ODS RTF, and it worked fine.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Hi Chris,
I am running SAS V8 now so can't try your ExcelXP tagsets. Will run it tomorrow on the different computer then.
I really appreciate your help !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top