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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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