BookmarkSubscribeRSS Feed
_Hopper
Obsidian | Level 7

My base code is this:

 
data cars;
set sashelp.cars;
run;
ods rtf file = "C:\Users\XYZODQ\test.rtf" style = beaconrtf;
proc report data = cars;
column ("~S={borderbottomcolor=black borderbottomwidth=2}Parameter" make model) drivetrain;
define make / 'Make';
define model / 'Model';
define drivetrain/'Drive Train';
run;
ods rtf close;
 
RTF produces fine as below:
_Hopper_0-1742576825184.png

Additionally, I would like to put a spanning header beneath make and model that says "Make and Model". How can I do this?

 
2 REPLIES 2
Ksharp
Super User

You want this ?

 

%let mypath=c:\temp;

ods rtf file="&mypath.\odsr_column_span.rtf" style=journal;
title "Complex Column Spanning";
data _null_; 
  set sashelp.cars(keep= make model drivetrain) end=last; 
  if _N_ = 1 then do; 
      dcl odsout obj(); 
      obj.table_start(); 
      obj.head_start(); 
	  ** Header row 1;
	  obj.row_start(type:"Header");
	  obj.format_cell(text: "Parameter", column_span:2,style_attr:"color=black backgroundcolor=white fontweight=bold  fontstyle=roman borderbottomcolor=black borderbottomwidth=2"); 
      obj.format_cell(text: "Drive Train", row_span:3, style_attr:"color=black backgroundcolor=white vjust=b fontweight=bold fontstyle=roman"); 
      obj.row_end(); 
	  ** Header row 2;
	  obj.row_start(type:"Header");
      obj.format_cell(text: "Make",  column_span:1, style_attr:"color=black backgroundcolor=white fontweight=bold  fontstyle=roman"); 
	  obj.format_cell(text: "Model", column_span:1, style_attr:"color=black backgroundcolor=white fontweight=bold  fontstyle=roman"); 
      obj.row_end(); 
	  ** Header row 3;
      obj.row_start(type: "Header"); 
      obj.format_cell(text: "Make and Model", column_span:2, style_attr:"color=black backgroundcolor=white fontweight=bold fontstyle=roman bordertopcolor=black bordertopwidth=2"); 
      obj.row_end(); 
      obj.head_end(); 
    end;
  ** row for every obs;
      obj.row_start(); 
      obj.format_cell(data: make, row_span:1); 
      obj.format_cell(data: model, row_span:1); 
      obj.format_cell(data: drivetrain, row_span:1); 
	  obj.row_end();
  if last then do; 
      obj.table_end(); 
  end; 
run; 
ods rtf close;
title; footnote;

Ksharp_0-1742631980837.png

 

Ksharp
Super User

Another easy and simple way is using this:

ods rtf file='c:\temp\temp.rtf' style=journal;
ods escapechar='~';
proc report data=sashelp.cars(obs=20) nowd style(header)={fontstyle=roman};
columns ('~S={borderbottomcolor=black borderbottomwidth=2}Parameter'
('~S={borderbottomcolor=black borderbottomwidth=2}Make          Model' 
('Make and Model' make model)))  ('Drive Train' drivetrain);
define make/'' style={just=c};
define model/'' style={just=c};
define drivetrain/'' style={just=c};
run;
ods rtf close;

Ksharp_0-1742635241077.png

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 561 views
  • 0 likes
  • 2 in conversation