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

Hi there,

 

I'm a SAS EG (7.1 HF1 (7.100.0.2002) (64-bit)) user trying to add to a customized template of my own some horizontal padding to table cells to avoid the numeric results to be too close as I have removed the vertical border lines from the table layout.

 

I have tried increasing cellpadding (seemed like a very promising parameter to change according to documentation) and also adding a pretext='   ' and posttext='   ' as suggested here but they don't make the desired change in my output. Maybe the reason is that I'm not writing it in the proper place inside the template. Here the code of my template:

 

proc template;                                                                
   define style times8p / store = SASUSER.TEMPLAT;                            
      parent = styles.default;                                                
      replace fonts /                                                         
         'TitleFont2' = ("Times",8pt,Italic)                             
         'TitleFont' = ("Times",8pt,Italic)                              
         'StrongFont' = ("Times",8pt,Bold)                                    
         'EmphasisFont' = ("Times",8pt,Italic)                                
         'FixedEmphasisFont' = ("Times, Courier",8pt,Italic)                  
         'FixedStrongFont' = ("Courier New, Courier",8pt,Bold)                
         'FixedHeadingFont' = ("Courier New, Courier",8pt,Bold)               
         'BatchFixedFont' = ("SAS Monospace,Courier New,Courier",8pt)         
         'FixedFont' = ("Courier New, Courier",8pt)                           
         'headingEmphasisFont' = ("Times",8pt,Bold Italic)                    
         'headingFont' = ("Times",8pt,Bold)                                   
         'docFont' = ("Times",8pt);                                           
      replace color_list /                                                    
         'fgB2' = CX000000                                                    
         'fgB1' = CX000000                                                    
         'fgA4' = CX000000                                                    
         'bgA4' = cxFFFFFF                                                    
         'bgA3' = cxFFFFFF                                                    
         'fgA2' = CX000000                                                    
         'bgA2' = cxFFFFFF                                                    
         'fgA1' = CX000000                                                    
         'bgA1' = CX000000                                                    
         'fgA' = CX000000                                                     
         'bgA' = cxFFFFFF;                                                    
      replace Output from Container /                                         
         background = colors('tablebg')                                       
         rules = GROUPS                                                       
         frame = BOX                                                          
         cellpadding = 7                                                      
         cellspacing = 2                                                      
         bordercolor = CX000000                                               
         borderwidth = 1;                                                     
      replace TitlesandFooters from Container /                               
         font = Fonts('TitleFont2')                                           
         foreground = colors('systitlefg'); 
	  class table /
		 frame = hsides
		 rules = groups
		 borderwidth = 1px
		 borderstyle = solid
		 bordercolor = black
		 borderspacing = 0
		 cellpadding = 10px
		 pretext = '   '
		 posttext = '   ';
	  context '.header' /
	  	borderbottomstyle = solid
		borderbottomcolor = black
		borderbottomwidth = 1px;
   end;                                                                       
run;

Here my test ouput where I have circled some examples of things that I would like to avoid/solve:

 

horizontal_padding.PNG

 

Thanks in advance for any tip or advice!!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@emera86 wrote:

Hi @RW9,

 

Thank you for your quick response, but is not exaclty what I was trying.

  • First of all I would like to implement the extra space through a template rather than including some text in my procedure. I would like a general solution not only for proc report but for every table on which my custom style is applied.
  • Secondly I don't want to fix a column width because that would oblige me to personalize the column width every time I produce a table to adjust it to the specific case: I just want a custom padding (let's say 10px) to be added on both sides of the cell content.

As you are asking for an example of what I have and what I would like to obtain here I'm providing a simple example to illustrate the issue. Here you have a table on which the column width is adjusted to the longer content, in this case the header text:

 

narrow.PNG

 

To beautify this table I would like to stablish some margin (padding-right and padding-left in CSS language) to the cells content as is shown in the following table on which the effect has been exaggerated and highlighted in yellow to help visualization:

 

wider.PNG

 

In CSS you can do it by defining the style of the padding on both sides to be 20px.

 

th {
padding-left:20px;
padding-right:20px;
}
td {
padding-left:20px;
padding-right:20px;
}

But I would like to implement it on my PROC TEMPLATE. What is the element that I need to modify? the name of the parameter that controls it? is there any way to implement some CSS code inside a PROC TEMPLATE?

 

Thank you for your help again and sorry if I wasn't clear in my first post.


The ods equivalent is style = [paddingleft = 20 paddingright=20] but you will want to pick a unit as PX, assuming that is pixel, is not supported, cm, em, in mm or pt.

 

Only valid in markup family, printer family and RTF destinations.

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

In the proc report, define for each column, make sure there is enough width to cover the full text:

proc report ...;
...
  define dead / style(column)={width=6cm};
  ...
run;

Probably alos a good idea to post sample required output in future rather than actual data Smiley Happy

emera86
Quartz | Level 8

Hi @RW9,

 

Thank you for your quick response, but is not exaclty what I was trying.

  • First of all I would like to implement the extra space through a template rather than including some text in my procedure. I would like a general solution not only for proc report but for every table on which my custom style is applied.
  • Secondly I don't want to fix a column width because that would oblige me to personalize the column width every time I produce a table to adjust it to the specific case: I just want a custom padding (let's say 10px) to be added on both sides of the cell content.

As you are asking for an example of what I have and what I would like to obtain here I'm providing a simple example to illustrate the issue. Here you have a table on which the column width is adjusted to the longer content, in this case the header text:

 

narrow.PNG

 

To beautify this table I would like to stablish some margin (padding-right and padding-left in CSS language) to the cells content as is shown in the following table on which the effect has been exaggerated and highlighted in yellow to help visualization:

 

wider.PNG

 

In CSS you can do it by defining the style of the padding on both sides to be 20px.

 

th {
padding-left:20px;
padding-right:20px;
}
td {
padding-left:20px;
padding-right:20px;
}

But I would like to implement it on my PROC TEMPLATE. What is the element that I need to modify? the name of the parameter that controls it? is there any way to implement some CSS code inside a PROC TEMPLATE?

 

Thank you for your help again and sorry if I wasn't clear in my first post.

ballardw
Super User

@emera86 wrote:

Hi @RW9,

 

Thank you for your quick response, but is not exaclty what I was trying.

  • First of all I would like to implement the extra space through a template rather than including some text in my procedure. I would like a general solution not only for proc report but for every table on which my custom style is applied.
  • Secondly I don't want to fix a column width because that would oblige me to personalize the column width every time I produce a table to adjust it to the specific case: I just want a custom padding (let's say 10px) to be added on both sides of the cell content.

As you are asking for an example of what I have and what I would like to obtain here I'm providing a simple example to illustrate the issue. Here you have a table on which the column width is adjusted to the longer content, in this case the header text:

 

narrow.PNG

 

To beautify this table I would like to stablish some margin (padding-right and padding-left in CSS language) to the cells content as is shown in the following table on which the effect has been exaggerated and highlighted in yellow to help visualization:

 

wider.PNG

 

In CSS you can do it by defining the style of the padding on both sides to be 20px.

 

th {
padding-left:20px;
padding-right:20px;
}
td {
padding-left:20px;
padding-right:20px;
}

But I would like to implement it on my PROC TEMPLATE. What is the element that I need to modify? the name of the parameter that controls it? is there any way to implement some CSS code inside a PROC TEMPLATE?

 

Thank you for your help again and sorry if I wasn't clear in my first post.


The ods equivalent is style = [paddingleft = 20 paddingright=20] but you will want to pick a unit as PX, assuming that is pixel, is not supported, cm, em, in mm or pt.

 

Only valid in markup family, printer family and RTF destinations.

emera86
Quartz | Level 8

Hi @ballardw,

 

Thank you for your suggestion, it took me straight to the solution. I'm using this template now that is working as I wanted:

 

proc template;                                                                
   define style times8p / store = SASUSER.TEMPLAT;                            
      parent = styles.default;                                                
         (...)
	  class table /
		 frame = hsides
		 rules = groups
		 borderwidth = 1px
		 borderstyle = solid
		 bordercolor = black
		 borderspacing = 0
		 cellpadding = 10px;
	  class cell /
	     paddingright = 15; /* Increase/decrease this number to change the spacing between one cell and the next one */
         (...)
   end;                                                                       
run;

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
  • 3104 views
  • 0 likes
  • 3 in conversation