BookmarkSubscribeRSS Feed
Dick_Shryock
Calcite | Level 5

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

5 REPLIES 5
Patrick
Opal | Level 21

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".

Dick_Shryock
Calcite | Level 5

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

manojinpec
Obsidian | Level 7

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

Doc_Duke
Rhodochrosite | Level 12

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

Patrick
Opal | Level 21

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1589 views
  • 3 likes
  • 4 in conversation