Sample 32014: Adding today's date to a report header in SAS® Web Report Studio
Overview
SAS Web Report Studio enables you to include seven dynamic text items in a header or footer (for a list, see SAS Note 20902). Another way to add dynamic text items to a header or footer is to place a Text object just below the header or just above the footer. Text objects can display measure and prompt values.
This sample explains how you can use SAS® Information Studio in order to create a measure data item that represents today's date. That measure is then inserted into a Text object that is placed directly beneath the report's header. In this way, it appears that today's date is part of the report's header.
Tip: Beginning with the second maintenance release for SAS Web Report Studio 4.31, you can insert prompt values into headers and footers.
This sample was written using the first maintenance release for SAS Information Map Studio 4.31. However, you can perform this task with version 3.1 and later. For version 3.1, the user interface is slightly different.
About the sample data
To create the Price Data information map used in the sample, you can submit the PROC INFOMAPS code on the Full Code tab in this sample. The steps in the sample refer to this information map.
Create a data item for today's date
- In SAS Information Map Studio, open the Price Data information map.
- Select Insert ► New Data Item to open the Data Item Properties dialog box.
- Enter a name for the new data item that will be today's date. This sample uses Today's Date.
- Click Edit to open the Expression Editor dialog box, and then specify these settings:
- For Type, select Date.
- From the Functions tab, select Date and Time to display a list of functions on the right.
- Select the Today() function and click Add to Expression.
Note: The TODAY function produces the current date in the form of a SAS date value, which is the number of days since January 1, 1960.
- Click OK to return to the Data Item Properties dialog box.
- Display the Classifications, Aggregations, Formats tab, and then specify these settings:
- Select Measure.
- Click Clear All to remove all selected aggregation types.
- Select the radio button for the Defined in expression aggregation options, then select only the Defined in expression (non-additive) option
- Beneath Format type, select Date/Time and then select DATE.
- Click OK.
- Save the information map.
Create the report header
- Open SAS Web Report Studio and select the information map that you just created. Make sure that you select the measure that represents today's date.
- Click Header and select Edit, and then enter some text in the Left Content section in the Edit Header dialog box. You will need to change the width of the Left content to 100% and the width of the Middle content to 0%. In this sample, the text is Sales and pricing information.
- Click OK to return to the layout.
- Insert a Text object in the first cell in the layout beneath the header.
- Right-click on the object and select Edit to open the Edit Text dialog box.
- Type some text in the box such as Today's Date.
- Select the measure that represents today's date from the Measure value drop-down list, and then click Insert.

- Click OK to return to the layout.
- Insert a table beneath the Text object.
- Right-click on the table and select Assign Data.
- Select the measure that represents today's date and move it to Hidden.
This what the layout looks like.
View the report
Click View to display the report.
Change the format of today's date
- Return to the Edit view, right-click on Today's Date in the Section Data pane, and select Format.
- In the Define a Format dialog box, change the type of format to Date.
- In the Options box, select the new format that you want to apply. In this sample, the format is June 26, 2002.

- Click OK and then view the report again.
Alternatives: Other Date Functions
The DATETIME function produces the current date and time of day as a SAS value that represents the number of seconds between January 1, 1960, and the current time. The TIME function produces the current time of day as a SAS time value. To create data items that represent the current date and time and the current time, follow the steps for creating today's date, but use these settings:
Setting | Current Time | Current Date and Time |
Function | TIME() | DATETIME() |
Formatting | Date/Time and TIME | Date/Time and DATETIME |
Additional Documentation
For more information about SAS Web Report Studio, see the SAS Web Report Studio documentation page.
For more information about SAS Information Map Studio, see the SAS Information Map Studio documentation page.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Before submitting this code, these tasks must be done:
- Make a copy of the SASHELP.PRICEDATA table, and then register the location of the copy as a library in metadata.
Note: For information about registering SAS libraries and tables, see Establishing Connectivity to a Library of SAS Data Sets.
- The location of the information map (specified by mpath), the PROC INFOMAPS statement, and the INSERT DATASOURCE statement must be modified to use the correct values for your environment.
/* This syntax is for use with SAS 9.2 or later */
%let mpath=/Shared Data/your-map-folder;
proc infomaps metauser="your-userID"
metapass="your-password"
metaserver="your-metadata-server.com"
metaport=8561
metarepository=Foundation
mappath="&mpath";
new infomap "Prices" auto_replace=yes;
insert datasource
sasserver="SASApp"
table="yourlib".pricedata
id="Prices";
insert dataitem column="Prices"."date"
id="Date";
insert dataitem column="Prices"."sale"
id="Unit Sale";
insert dataitem column="Prices"."regionName"
id="Region";
insert dataitem column="Prices"."productName"
id="Product";
save;
* list _all_;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample explains how to create a measure data item that represents today's date. That measure is then inserted into a Text object that is placed directly beneath the report header. In this way, it appears that today's date is part of the report's header.
Type: | Sample |
Topic: | Data Management ==> Data Sources ==> Information map Query and Reporting ==> Interactive Querying Query and Reporting SAS Reference ==> Functions ==> Date and Time ==> DATE SAS Reference ==> Functions ==> Date and Time ==> DATETIME SAS Reference ==> Functions ==> Date and Time ==> TIME SAS Reference ==> Functions ==> Date and Time ==> TODAY
|
Date Modified: | 2012-08-01 15:04:43 |
Date Created: | 2008-05-06 16:03:53 |
Operating System and Release Information
SAS System | SAS Information Map Studio | Microsoft® Windows® for x64 | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Advanced Server | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Datacenter Server | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Server | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Professional | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows NT Workstation | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Datacenter Edition | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Enterprise Edition | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Standard Edition | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows XP Professional | 3.1 | | 9.1 TS1M3 SP4 | |
SAS System | SAS Web Report Studio | Microsoft® Windows® for x64 | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Advanced Server | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Datacenter Server | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Server | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Professional | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows NT Workstation | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Datacenter Edition | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Enterprise Edition | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Standard Edition | 3.1 | | 9.1 TS1M3 SP4 | |
Microsoft Windows XP Professional | 3.1 | | 9.1 TS1M3 SP4 | |
64-bit Enabled AIX | 3.1 | | 9.1 TS1M3 SP4 | |
64-bit Enabled Solaris | 3.1 | | 9.1 TS1M3 SP4 | |
HP-UX IPF | 3.1 | | 9.1 TS1M3 SP4 | |