BookmarkSubscribeRSS Feed
dmanteigas
Fluorite | Level 6

Hi there,

 

I produce a lot of tables with multiple header rows using either proc report or proc tabulate. I use a custom template which produces the following output header:

 

 

Image1.PNG

 

 

However, what I want directly from the SAS output is the following:

 

image2.PNG

 

Currently I do this "by hand" in Microsoft Word. However I would like to know if there is a way to do it directly in SAS. I found this page  - http://support.sas.com/kb/46/022.html - but as far as I understand, this is applicable to individual cells of the table and not in the header. Does anyone know how to customize this, either on proc report/tabulate or on SAS styles?

 

Regards,

 

David

8 REPLIES 8
ballardw
Super User

If you are referring to headers that span columns of other variables you may have to be very careful in defining exactly what you want. Borders affect an entire cell and in Proc tabulate can be addressed with the CLASSLEV statement. But since it appears that your only want to display a "border" for part of a cell then you really do not have a border. At least other cells on that row do not appear in your example.

 

You might be able to get a similar affect by using bordertopwidth that varies with the calues of what you display as Var1 similar to traffic highlighting but I doubt that is going to be a simple generic solution.

 

You might try suppressing the bottom border entirely

dmanteigas
Fluorite | Level 6

Hi ballardw,

 

I currently have this specification for the header within proc template:

   style header /
         fontfamily="Times New Roman"
         fontsize=12pt
		 fontweight=bold
         borderbottomwidth=0.5pt
		 bordertopwidth=0.5pt
		 textalign=left
		 verticalalign=middle
		 height=0.39in;

Do you suggest that I remove the borders and mannually add them using proc report or proc tabulate? Or have I misunderstand? How should I do that?

 

Regards

ballardw
Super User

Since it appears that you want to do a lot of by-cell appearance changes then you may want to set all of the header top and bottom widths to 0 and then use style overrides in the table construction where it affects the header values.

OR

Leave you current Ods style as it is for bottom widths and then use style overrides for the spanning header to remove the borders that you don't want.

 

Another potential option but likely to be hard to maintain is take a simple table that you have modified in Word. Save it as RTF and see if you can find the RAW rtf codes to do what you want. You possibly could then use Escapechar and the RAW predicate with the cell contents to get the behavior you want. I am not saying that will be trivial or easy to maintain but might work.

Cynthia_sas
SAS Super FREQ

Hi:

   I would tend to do this with the text_decoration style attribute, as shown below....using PROC REPORT and ODS ESCAPECHAR in the spanning header.

 

cynthiatext_decoration_underline.png

dmanteigas
Fluorite | Level 6

Hi Cynthia,

 

That option just subscript the word and does not "create" a bottom border. Thank you for the answer, but it will not work as a solution to me  🙂

 

Regards,

 

David

ballardw
Super User

Post the data you used in the form of a datastep and the code you used that generated a subscript instead of an underline.

dmanteigas
Fluorite | Level 6

Already found a solution using proc report:

ods escapechar="£";

proc report data=work._tmp;
	columns 	('£S={borderbottomcolor=black}' VAR1)
                     ('Group VAR', VAR2.1, VAR2.2)
		    ('£S={borderbottomcolor=black}' VAR3);

	define VAR1 / group noprint style(header)={borderbottomwidth=0.5};
	define VAR2.1 / group noprint style(header)={borderbottomwidth=0.5 bordertopwidth=0.5};
        define VAR2.2/ group noprint style(header)={borderbottomwidth=0.5 bordertopwidth=0.5};
        define VAR3 / group noprint style(header)={borderbottomwidth=0.5};

run;

 And by changing the custome style I've created by setting the default borders to 0 on the Header block and putting top aod bottom borders on the Table block. 

 

Thank you all for the help aod really helpful suggestions.

 

Regards,

 

David

Cynthia_sas
SAS Super FREQ
Hi, David:
Notice that I used a different style attribute. I did NOT attempt to change the borders. I used TEXTDECORATION -- if using my code does NOT work for you, as shown in my screen shot, then that is a question for Tech Support.

As for why your posted code does not work, I do NOT understand how you might be getting a subscript -- I can understand how RTF might ignore your border control, because you don't specify a unit of measure for your width and generally ODS RTF needs to have a unit of measure in either IN, CM or PT so that the attribute unit can be converted to TWIPS -- so it seems to me that a bottom width of .5 with no unit will translate to .5 pixels (I think), which seems impossibly small. You may want to work with Tech Support on this issue, as well, unless adding a unit of measure like PT or IN or CM doesn't work for you.

cynthia

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
  • 8 replies
  • 3859 views
  • 1 like
  • 3 in conversation