BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
DougHold
Obsidian | Level 7

Here are 3 tables from sashelp.cars dataset. I would like to combine them into one excel report.

proc report data=sashelp.cars(obs=3) out=Porsche;   
	title "Porsche";
	where make = 'Porsche';
	column Make Model Type Origin DriveTrain MSRP;  

proc report data=sashelp.cars(obs=3) out=BMW;   
	title "BMW";
	where make = 'BMW';
	column Make Model Type Origin DriveTrain MSRP;

proc report data=sashelp.cars(obs=3) out=Audi;   
	title "Audi";
	where make = 'Audi';
	column Make Model Type Origin DriveTrain MSRP;
run;

However, I don't understand why the titles are all named as the last table 'Audi' when combined like this ?

ods excel file="Stacked.xlsx" 
options(sheet_interval='none' embedded_titles='yes');
proc report data=Porsche;
proc report data=BMW;
proc report data=Audi;
run;
ods excel close;

What I want is this, each table retaining it's proper title:

DougHold_0-1674247108100.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
TITLE statements stay in effect until you reset it.
Use:
TITLE;

To reset the title and have no title.
Your last set of code has no title statement so it uses the title from your last code as it hasn't been reset.

ods excel file="Stacked.xlsx"
options(sheet_interval='none' embedded_titles='yes');
title 'Porsche';
proc report data=Porsche;
title 'BMW';
proc report data=BMW;
title 'Audi';
proc report data=Audi;
run;
title; *reset;
ods excel close;

You may want to look into BY groups though as that could make this a lot easier:

title "#ByValue1";
proc report data=sashelp.cars;
by Make;
where make in ( 'Audi', 'BMW', 'Porsche');
column Make Model Type Origin DriveTrain MSRP;
run;

View solution in original post

2 REPLIES 2
Reeza
Super User
TITLE statements stay in effect until you reset it.
Use:
TITLE;

To reset the title and have no title.
Your last set of code has no title statement so it uses the title from your last code as it hasn't been reset.

ods excel file="Stacked.xlsx"
options(sheet_interval='none' embedded_titles='yes');
title 'Porsche';
proc report data=Porsche;
title 'BMW';
proc report data=BMW;
title 'Audi';
proc report data=Audi;
run;
title; *reset;
ods excel close;

You may want to look into BY groups though as that could make this a lot easier:

title "#ByValue1";
proc report data=sashelp.cars;
by Make;
where make in ( 'Audi', 'BMW', 'Porsche');
column Make Model Type Origin DriveTrain MSRP;
run;
DougHold
Obsidian | Level 7

Thanks for clarifying!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1220 views
  • 0 likes
  • 2 in conversation