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!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 632 views
  • 0 likes
  • 2 in conversation