The SAS Output Delivery System and reporting techniques

Add custom table header text to a style template

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

Add custom table header text to a style template

Hi there,

 

I'm a SAS EG 7.1 user. I'm trying to add a new feature to one of my home-made SAS style templates: a custom text (always the same) for the table header. For a reference, I would like to achieve what appears in this example as "Table Header with Leading and Trailing Blanks". I attach an image for clarification:

 

Example

 

I have isolated the part of the code from the example that I thought that was doing the trick but nothing changes in my output file. I don't know if it's related with some other parameters that I have to change also (as header area height or something like these).

 

 

Here my original template with the new inserted code in blue color:

 

proc template;                                                                
   define style customstyle / store = SASUSER.TEMPLAT;                             
      parent = styles.default;        
 
      style fonts /                                                           
         'docFont' = ("Courier",8pt)                                          
         'headingFont' = ("Courier",8pt,bold)                                 
         'headingEmphasisFont' = ("Courier",8pt,bold italic)                  
         'FixedFont' = ("Courier New, Courier",8pt)                           
         'BatchFixedFont' = ("SAS Monospace,Courier New,Courier",8pt)         
         'FixedHeadingFont' = ("Courier New, Courier",8pt,bold)               
         'FixedStrongFont' = ("Courier New, Courier",8pt,bold)                
         'FixedEmphasisFont' = ("Courier, Courier",8pt,italic)                
         'EmphasisFont' = ("Courier",8pt,italic)                              
         'StrongFont' = ("Courier",8pt,bold)                                  
         'TitleFont' = ("Courier",8pt,italic)                                 
         'TitleFont2' = ("Courier",8pt,italic);      
 
      style color_list /                                                      
         'bgA' = cxFFFFFF                                                     
         'fgA' = CX000000                                                     
         'bgA1' = CX000000                                                    
         'fgA1' = CX000000                                                    
         'bgA2' = cxFFFFFF                                                    
         'fgA2' = CX000000                                                    
         'bgA3' = cxFFFFFF                                                    
         'bgA4' = cxFFFFFF                                                    
         'fgA4' = CX000000                                                    
         'fgB1' = CX000000                                                    
         'fgB2' = CX000000;          
 
      style Output from Container /                                           
         borderwidth = 1                                                      
         bordercolor = CX000000                                               
         borderspacing = 2                                                    
         cellpadding = 7                                                      
         frame = BOX                                                          
         rules = GROUPS                                                       
         backgroundcolor = colors('tablebg');  
 
      style TitlesandFooters from Container /                                 
         color = colors('systitlefg')                                         
         font = Fonts('TitleFont2'); 

   end;     

   edit Base.Datasets.Members;
      header hd1;
      define hd1;
         text"CUSTOM HEADER TEXT TEST";
      end;
   end;
run;

Any suggestion, hint or solution would be much appreciated!! Smiley Happy


Accepted Solutions
Solution
‎05-18-2017 11:10 AM
SAS Super FREQ
Posts: 8,740

Re: Add custom table header text to a style template

[ Edited ]

Hi:

  Well, part of the confusion is due to your assumption that you change the TABLE header for an output object in a STYLE template. Output Object TABLES, used by SAS procedures, such as MEANS, CONTENTS, DATASETS, REG, etc are changed by modifying the TABLE template -- you don't change header text for a procedure's template in a STYLE template.

 

  EG only surfaces STYLE templates to you in the Style Wizard. The place where you change BASE.DATASETS.MEMBERS is in the TABLE template. So that is not going to work from the EG Style Wizard.

 

  This paper may help illustrate the differences. https://support.sas.com/resources/papers/proceedings09/227-2009.pdf  There are 4 main template types: table, style, tagset and statgraph (there are other templates possible, but those are the "big" ones). There are some utility programs in the beginning of the paper.

 

  However, rather than fiddle with TABLE templates, I find it much easier to create an output dataset and then do whatever "cosmetics" I want with PROC REPORT or PROC PRINT. Like this:spanning_header_datasets.png

 

This is much easier than TABLE templates and it allows you to apply style changes for the different extra header information.

 

cynthia

View solution in original post


All Replies
Contributor
Posts: 31

Re: Add custom table header text to a style template

I think I've found the problem, but still I don't know how to solve it.

The template in the example was applied to a proc datasets so it makes sense that the "Base.Datasets.Members" parameters were not applied to my proc print/proc report procedures output. What I don't know is what are the analogous "Base.Datasets.Members" to the other procedures... Smiley Frustrated

Super User
Posts: 10,466

Re: Add custom table header text to a style template

Proc Print, Report and Tabulate unfortunately do not have a base table template definition at all that we can modify. So that approach won't work for them.

 

For some tasks you might be able to use ODS File print and the Base.Datastep.Table definition. Might.

 

For other procedures you may try 1) Make the results window the current active window, 2) right click on the Results in the window not the title 3) click on templates 4) navigate through the various procedures in SASHELP.Templmst. You can see the tables available and the table definition syntax (which may be quicker than using proc template for ones you are not sure of).

 

ODS Trace on; before a procedure will show the names of tables created by a specific procedure run that you may hunt for but the ones reported for Proc Print, Tabulate and Report can't be found, at least now when I look.

Contributor
Posts: 31

Re: Add custom table header text to a style template

Dear @ballardw,

 

Thank you for your quick response.

 

Could you please explain the steps to get to the SASHELP.Templmst content a little bit more in detail? I'm using SAS EG 7.1 and I can't follow you in the step #2 "right click on the Results in the window not the title". I'm trying what I've understood from your instructions but only the "Select All" option is available as you can see in the screenshot I'm attaching. The red arrow points to the place where I right-clicked.

 

test_header.png

Super User
Posts: 10,466

Re: Add custom table header text to a style template

Don't use EG so have no idea how to access the template stores with point and click. Proc Template will let you list things in the template stores with list instruction.

Contributor
Posts: 31

Re: Add custom table header text to a style template

Thanks for you help @ballardw,

 

I have tried to explore the list statement of the PROC TEMPLATE and still haven't found what I'm looking for.

It seems that I can change a lot style settings but the header text... I don't know what else to try...

Solution
‎05-18-2017 11:10 AM
SAS Super FREQ
Posts: 8,740

Re: Add custom table header text to a style template

[ Edited ]

Hi:

  Well, part of the confusion is due to your assumption that you change the TABLE header for an output object in a STYLE template. Output Object TABLES, used by SAS procedures, such as MEANS, CONTENTS, DATASETS, REG, etc are changed by modifying the TABLE template -- you don't change header text for a procedure's template in a STYLE template.

 

  EG only surfaces STYLE templates to you in the Style Wizard. The place where you change BASE.DATASETS.MEMBERS is in the TABLE template. So that is not going to work from the EG Style Wizard.

 

  This paper may help illustrate the differences. https://support.sas.com/resources/papers/proceedings09/227-2009.pdf  There are 4 main template types: table, style, tagset and statgraph (there are other templates possible, but those are the "big" ones). There are some utility programs in the beginning of the paper.

 

  However, rather than fiddle with TABLE templates, I find it much easier to create an output dataset and then do whatever "cosmetics" I want with PROC REPORT or PROC PRINT. Like this:spanning_header_datasets.png

 

This is much easier than TABLE templates and it allows you to apply style changes for the different extra header information.

 

cynthia

Contributor
Posts: 31

Re: Add custom table header text to a style template

Thanks for your help @Cynthia_sas!!

 

That's exactly what I needed!!

And thank you for such a detailed answer: very useful and easy to follow.

 

Woman Very Happy

 

 

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 193 views
  • 0 likes
  • 3 in conversation