Hi,
I am trying to create titles in an ODS report with multiple tables. I would like one title above all tables and then one title for each table. The table are created by iteration. The title for each table is put in a variable. Output that i want:
Title 1
Title 2
[table 1]
Title 3
[table 2]
But there seems to be something that I do not understand about how the titles are generated since I get very strange results. Some test code:
* Open ods;
ods listing close;
ods graphics on;
ods html file="&output_folder.\&cluster_label.\&cluster_label..html" headtext="<style>p,hr {display:none}</style>"
style=Journal
gpath="&output_folder.\&cluster_label.\graph"
image_dpi=300;
ods text='<div><h1 align="center">Cars</h1></div>';
%macro car_var;
data &var_name.; set sashelp.cars;
if type = "&var_name.";
run;
Title2 "<H2>&var_title.</H2>";
proc print label
data=&var_name.;
run;
%mend car_var;
%Let var_name = Sports ; %Let var_title = Sports; %car_var
%Let var_name = Sedan ; %Let var_title = Sedan; %car_var
ods html close;
Results:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
What am I doing wrong? Why is the ods text printed after title2? Why is title2 the same for both tables?
From your code it appears you are trying to control the html appearance. Look at your htm with a text editor, not an html viewer. You will see that the title text has been put within html tags such that it will not render as headers.
I would suggest trying "bare" title text to see if it appears as needed. If you want to modify all of the titles then create a modified ODS template with different characteristics.
Also using proc report or tabulate a variable can have role of PAGE which may help.
Whilst not a direct answer to your question, why not just do:
proc sort data=sashelp.cars out=cars;
by type;
run;
proc report data=cars;
columns make origin;
by type;
title "Cars";
title2 "#byvar1";
run;
No need for all that code, the by syntax should suffice.
Thank you for your reply. I posted a simplified code since the real code is quite long and complicated. The reason I want to do it this way is that my code includes a transpose part which is done separetly for each variable. If done on all variables at ones, transpose will convert number formats.
orginial table looks something like this
country year var1 var2
1 2001 1 0.1
1 2002 2 0.2
1 2003 1 0.5
2 2001 1 0.1
2 2002 2 0.2
2 2003 1 0.5
The program makes one table per variable and presents it like this. The macro also makes it possible for me to exclude variables if I don't want them in a particular analysis.
var1
country 2001 2002 2003
1 1 2 1
2 1 2 1
var2
country 2001 2002 2003
1 0.1 0.2 0.5
2 0.1 0.2 0.5
From your code it appears you are trying to control the html appearance. Look at your htm with a text editor, not an html viewer. You will see that the title text has been put within html tags such that it will not render as headers.
I would suggest trying "bare" title text to see if it appears as needed. If you want to modify all of the titles then create a modified ODS template with different characteristics.
Also using proc report or tabulate a variable can have role of PAGE which may help.
Thank you! I suppressed the titles and used the ods text feature instead and that worked fine.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.