Hi,
It sort of depends on what your definition of "automatic" is. Consider the following program:
[pre]
proc sql;
select distinct(name) into :allname separated by ', '
from sashelp.class
where sex = 'F';
quit;
%put -----## What is macro var: &allname;
ods html file='c:\temp\macro_title.html' style=sasweb;
title 'The Report For';
title2 "&allname";
proc means data=sashelp.class min mean max;
where sex='F';
var age height;
run;
ods html close;
[/pre]
The INTO, used on the SELECT clause creates a macro variable. You can use "SEPARATED BY" in order to put commas or whatever punctuation you need in the list of names (or dates). The macro variable is going to be &ALLNAME -- notice how it appears in the log when you use &ALLNAME in the %PUT statement. %PUT does not need to have quotes around the macro variable. But, the title statement string needs to be in quotes, so for &ALLNAME to be resolved it needs to be enclosed in double quotes, ON the TITLE statement,
Remember that you may need to use PUT statements in order to get formatted dates into your macro variable. This is because the date variable will be internally stored as a number -- an offset of the number of days since Jan 1, 1960.
So, you may need to do something like this:
[pre]
select distinct(datevar) format=mmddyy10. into :alldate separated by ', '
[/pre]
Good luck,
cynthia