BookmarkSubscribeRSS Feed

How to create a user-defined report in SAS Model Manager

Started ‎12-21-2015 by
Modified ‎01-06-2016 by
Views 1,490

Users often want to create user-defined reports specific to their organization and governance requirements. You can define such a report within SAS Model Manager so that the reports appear to be 'out of the box'. To accomplish this you need to create the code, add some SAS Model Manager-specific statements and subsequently locate the code where SAS Model Manager can access it. 

 

 

REQUIRED INPUTS

 

  • REPORT CODE   a  SAS program that creates the report
  • MACRO CODE    a  SAS program that lists any SAS Model Manager global macros used in the report
  • XML FILE            a  Report template file that specifies report requirements, (i.e., name, # of models)

Once these files have been uploaded to the content server, the report will appear as one of options in the ‘Reports’ drop down selection box.

 

 

CREATING THE INPUT FILES

 

  1.   WRITE AND TEST THE CODE that creates your report

         

        Add Model Manager wrapper code   this code allows the user to select format/style

 

        Filename mmreport catalog "sashelp.modelmgr.reportexportmacros.source";

        %include mmreport;

        %MM_ExportReportsBegin(fileName=report-name);

 

            … your-user—defined-report-code

 

        %MM_ExportReportsEnd;

 

2.  CREATE MACRO CODE FILE

     This is a required file.  If your report doesn’t use any global macros, create a SAS program with a comment in it.

 

               Sample program to define macros:

                                %let _MM_User = longj5;

                                %let _MM_Password = AristotleAndSocrates;

 

3.  EDIT THE .XML TEMPLATE FILE

SAS Model Manager provides a sample report template that you can use as a model for your XML template.  A best practice is to open the model XML template and save the template using another name. To open a sample report template, follow these steps:

 

Select Tools .......  Manage Templates to open the SAS Model Manager Template Editor.

Select File .....  Browse .....  Browse Templates. Select UserReportTemplate.xml and click OK.

Select File .....  Save As...... Enter a name in the File name field and click OK.

 

The UserReportTemplate.xml file has arguments in quotation marks that you modify for your report. Replace the text in quotation marks with values that are appropriate for your report. See the argument descriptions below.

  • Add the SAS ‘Report Code’ program name to the filename argument for <Code>

            for example        < Code filename = “createforecastgraph.sas” >

 

  • Add the SAS ‘Macro Code’ program name to the filename argument for <PreCode>

            for example       < PreCode filename = “SASMM_Macros.sas” >

 

Here is the report template XML definition edited to reflect your report

 

 img6.jpg

 

4.  UPLOAD THE FILES TO THE CONTENT SERVER

     After you have the two SAS programs for your user report, follow these steps to upload them to the SAS Content Server:

     

      Select Tools ..... Manage Templates to open the SAS Model Manager Template Editor.

   

      img1.jpg

  

 

       Select File ..... Open, select the program in the Open window, and click OK.

 

       img2.jpg

 

        Select File .....  Upload File to upload the program to the SAS Content Server.

 

        im3.jpg

 

       Repeat steps 2 and 3 to upload the second and third file.  NOTE:  upload the macro file LAST !

 

 

 

EXECUTING A USER DEFINED REPORT  

 

 

        At the Version level  Right Mouse Click on New Report

       img4.jpg

 

 

        The report is named using the value contained in the 'displayName= ' paramter of the XML

.

         img5..jpg

 

         Choose the model for use in the report and change the output file name and description to something useful.

 

img7.jpg

 

 

 

Version history
Last update:
‎01-06-2016 01:42 PM
Updated by:
Contributors

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags