We’re smarter together. Learn from this collection of community knowledge and add your expertise.

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

by SAS Employee jkl on ‎12-21-2015 08:24 AM - edited on ‎01-06-2016 01:42 PM by Community Manager (815 Views)

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

 

 

 

Contributors
Your turn
Sign In!

Want to write an article? Sign in with your profile.