Desktop productivity for business analysts and programmers

Having trouble creating a date variable to use in report headings

Reply
Contributor
Posts: 25

Having trouble creating a date variable to use in report headings

Hi,

I would like to add a date to my reports both in the heading and the file name when I export them.  Can someone help.

Thanks,

-d

Respected Advisor
Posts: 3,837

Having trouble creating a date variable to use in report headings

You could use syntax like below:

title "This report created on %sysfunc(today(),yymmddn8.)";
proc print data=sashelp.class;
run;


%put &sysdate;

title "This report created on %sysfunc(today(),yymmddn8.)";
proc print data=sashelp.class;
run;

There is also an automatic macro var &sysdate which could be used. Just be aware that the value of this var is the date of when you started your session - and with some people having sessions open for days the value of this var can become a bit "outdated".

Contributor
Posts: 25

Having trouble creating a date variable to use in report headings

Patrick, that was helpful but not exactly what I'm looking for (poorly worded question).  I have a variable named RptDate that I want to use in the report heading.  It could be any date or date range it is text.

I have tried "Emergency Department data for " &RptDate   and "Emergency Department data for &RptDate"  and both just produce the literal &RptDate.

I'm missing somthing very fundament here, but can't seem to put my finger on it.

Thanks,

-d

Frequent Contributor
Posts: 138

Having trouble creating a date variable to use in report headings

Most likely the rptdate is not resolving . Could you please share the code where rptdate is declared or if log can be shared. Smiley Happy

Valued Guide
Posts: 2,111

Having trouble creating a date variable to use in report headings

Dick,

If RptDate is a data value that you are reading in, then you need to use the CALL SYMPUT or CALL SYMPUTX macro functions to assign the data value to a macro variable's value and then use the macro variable in the TITLE statement.

This works if you have one value for RptDate for the entire report.  Otherwise, you will need to either bust the report apart so there are multiple reports (one for each RptDate) or use the BY capability for the TITLE statements to insert the BY-variable into the Title. (Output data set names can use MACRO variables, but not the BY functionality).

Doc Muhlbaier

Duke

Respected Advisor
Posts: 3,837

Having trouble creating a date variable to use in report headings

You have to share some sample code/explain your data better in order to give you a good answer.

May be below sample is helpful for you:

data have;
   set sashelp.class;
   retain rptdate;
   rptdate='01JAN2011 - 10Jan2011';
run;

options nobyline;
title "RPTDATE has value #BYVAL(rptdate)";
proc print data=have;
   by rptdate;
run;

HTH

Patrick

Ask a Question
Discussion stats
  • 5 replies
  • 227 views
  • 3 likes
  • 4 in conversation