Ad Hoc Reports

Overview

To create an ad hoc report, you must first write a SAS report program. When the report code is ready, you run the Create Ad Hoc Report wizard and copy your program to the SAS Editor tab. You then submit your program. Unlike the user-defined report, the ad hoc report does not require auxiliary files to be uploaded to the SAS Content Server.
To create your report output in either HTML, PDF, RTF, or Excel, you modify your report with code that is provided by SAS that enables you specify the report output format. The code that you need to add to your program is included in the steps to create an ad hoc program.
If you find an error in your report code, you must delete the report in the Project Tree, fix your code in your source file, and run the Create Ad Hoc Report wizard again.

Create an Ad Hoc Report

To create an ad hoc report, you must first create a SAS program. Test your program in SAS before you run your program as a SAS Model Manager ad hoc report. You copy the SAS program into the SAS Editor of the Create Ad Hoc Report window.
To create an ad hoc report, follow these steps:
  1. Expand the version folder Version Icon.
  2. Right-click the Reports node and select Reportsthen selectCreate Ad Hoc Report. The Create Ad Hoc Report window appears.
  3. In the Select Models table, select any number of models for the report.
  4. Either add the following code to your report program or copy the code to the SAS Editor. This code defines the report output format, such as HTML or PDF:
    Filename mmreport catalog "sashelp.modelmgr.reportexportmacros.source";
    %include mmreport;
    %MM_ExportReportsBegin(reportFormat=report-format, fileName=report-name);
              …
       add-your-ad-hoc-code-here
              …
    %MM_ExportReportsEnd(reportFormat=report-format);
    
    Replace report-format in the %MM_ExportReportsBegin macro with one of the following values: HTML, PDF, RTF, or Excel.
    Replace report-name with the name of your ad hoc report. The characters @ \ / * % # & $ ( ) ! ? < > ^ + ~ ` = { } [ ] | ; : ‘ " cannot be used in the name.
  5. Copy your SAS program to the SAS editor. Make sure that your report program is enclosed by the SAS code that defines the report output format. You can click the Macro Variables tab to view a list of the Model Manager macro variables that can be accessed by your program.
  6. Type the report name and a description for the report in the Report Properties table.
  7. Click OK. SAS Model Manager runs the report and creates a node under the Reports node using the name that you provided in the Report Properties table. The new node contains the output files that were created by running the report.
    A message box confirms that the report either completed successfully or failed. If the report failed, click Details to review the errors in the SAS log.

Example Ad Hoc Report

The following example code lists the score results in an HTML output format:
Filename mmreport catalog "sashelp.modelmgr.reportexportmacros.source";
%include mmreport;
libname myDatSet "\\myserver\myDataSets\hmeq";

%MM_ExportReportsBegin(reportFormat=html, fileName=myDataSet); 
proc print data=myDatSet.scoretable;
run;
quit;


%MM_ExportReportsEnd(reportFormat=html);
When you include this program in the Create Ad Hoc Report window, it looks like this:
Create Ad Hoc Report Window
After you click OK, SAS Model Manager creates the report and places the report output under the Reports folder in the Project Tree:
Ad Hoc Report in the Project Tree
The following HTML output displays selected rows of 5000 possible rows of output:
Ad-Hoc Report Output