I have a SAS dataset that has one column and eight rows. The column is a date field and the eight rows each contain a different date. Is there a way to pull these dates into a report title automatically, for example...
"Disease Management Summary Report"
"Strategy Date(s): 3/8/2007, 4/1/2007, 5/15/2007, 5/28/2007"
It sort of depends on what your definition of "automatic" is. Consider the following program:
select distinct(name) into :allname separated by ', '
where sex = 'F';
%put -----## What is macro var: &allname;
ods html file='c:\temp\macro_title.html' style=sasweb;
title 'The Report For';
proc means data=sashelp.class min mean max;
var age height;
ods html close;
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:
select distinct(datevar) format=mmddyy10. into :alldate separated by ', '
Thank you Cynthia. I'm pretty new to SAS so your answer is a little greek to me. I will study up on Macro variables because I have only heard the term but never actually done anything with one. I will work to make sense of your coding example.