Subject: REXX Shell Program For EVENT

From: Gerry <[email-masked]>
Date: Mon, 17 Jun 96 15:39:42 EDT

Don:

This is the REXX shell for the EVENT program. Rather than having SAS do
"housekeeping", the REXX performs this task (checking for files, etc.).
It also does some session management stuff (record the program's usage,
turn off the system messaging, etc.).

It then "builds" the SAS program. We compile our SAS applications, both
Data Step and Macros. The program built just issues Libname, and Options
statements and invokes the macro.

This is basically analogous to a startup script on Unix.

-Gerry

-------------------------- EVENT Rexx Shell Program ---------------------

/*------------------------------- EVENT ------------------------------*/
/*                                                                    */
/* The code loads and invokes the 'EVENT' program (implemented as a   */
/* compiled SAS macro), which performs event-date based data access   */
/* from the CRSP database.                                            */
/*                                                -Gerry              */
/*                                                                    */
/*--------------------------------------------------------------------*/

Address COMMAND                   /* Bypass The CMS Command Processor */

'EXEC CMSCOUNT 68'                     /* Record This Program's Usage */

'EXEC SYSMSG OFF ( NOMSG'                /* Turn Off System Messaging */

/*---------------- Get The User Original VMOUT Colors ----------------*/

Parse Value Diag(08, 'Q SCREEN') With 'VMOUT' COLOR ATTR '15'x

HI = '1d08'x                                           /* Hiliting On */
LO = '1d10'x                                          /* Hiliting Off */

/*----------------- Check For Required Program Files -----------------*/

'STATE 0SASMACR EVENT A1'             /* Check If EVENT Module Exists */
MOD_RC = RC

If (MOD_RC > 0) Then Signal MISSING_FILE     /* If Not, Tell The User */

'STATE 0FORMATS CRSPDATE A1'          /* Check If Formats File Exists */
FOR_RC = RC

If (FOR_RC > 0) Then Signal MISSING_FILE     /* If Not, Tell The User */

'VMFCLEAR'                                        /* Clear The Screen */

Call Diag 8, 'SCREEN VMOUT DEF'                     /* Default Colors */

Say ' '
Say 'Beginning' || HI || 'EVENT' || LO || 'program initialization ...'

/*------------ Generate The File To Run The EVENT Program ------------*/

Push 'FILE' EVENT SAS A
Push 'INP %Event'
Push 'INP         MPRINT NODATE /* NOSOURCE */ ;'
Push 'INP Options Fmtsearch=(CRSPDATE CRSPFMT) MSTORED SASMSTORE=EVENT'
Push 'INP Libname EVENT "A" ;'
Push 'INP                    '
Push 'INP /* Load The EVENT Program - Gerry */'

Address CMS 'XEDIT' EVENT SAS A '( NOPROF NOMSG'
Address CMS 'EXEC SAS EVENT - T'
SYSRC = RC                             /* Hold The System Return Code */

If (SYSRC = 0) Then             /* Run Ok, Remove Program & Log Files */
   Do
     Address CMS 'ERASE EVENT SAS    A'
     Address CMS 'ERASE EVENT SASLOG A'
   End
  Else                                  /* Problem, Keep The Log File */
   Do
     Address CMS 'ERASE EVENT SAS A'
     Signal PROGRAM_ERROR
   End

Call Diag 8, 'SCREEN VMOUT' COLOR ATTR      /* Return Original Colors */

'EXEC SYSMSG ON ( NOMSG'              /* Turn On The System Messaging */

Exit                                           /* We're Out of Here ! */

/*--------------------------------------------------------------------*/
/*                A Required Program File Is Missing                  */
/*--------------------------------------------------------------------*/

MISSING_FILE:

  'VMFCLEAR'                                      /* Clear The Screen */

  Call Diag 8, 'SCREEN VMOUT DEF'                   /* Default Colors */

  Say ' '

  Call Diag 8, 'SCREEN VMOUT RED'
  Say HI || '    ERROR:' || LO
  Call Diag 8, 'SCREEN VMOUT DEF'

  Say ' '

  If (MOD_RC > 0) Then
     Do
       Say '     The EVENT program module,' || HI || ,
       '0SASMACR EVENT A' || LO || ', is missing'
       Say '     from the ''A'' disk !  Please contact' || ,
           ' the Manager of User'
       Say '     Services for further assistance.'
     End
    Else
  If (FOR_RC > 0) Then
     Do
       Say '     The file' || HI || '0FORMATS CRSPDATE A' || LO || ,
           'is missing from the ''A'' disk.'
       Say '     This file must be present for the ' || ,
           'EVENT program to execute'
       Say '     properly. Contact the Manager of User' || ,
           ' Services for further'
       Say '     assistance.'
     End

  Say ; Say

  Call Diag 8, 'SCREEN VMOUT' COLOR ATTR    /* Return Original Colors */

  'EXEC SYSMSG ON ( NOMSG'            /* Turn On The System Messaging */

Exit -9999

/*--------------------------------------------------------------------*/
/*       A Program Error Occurred, Tell The User And Then Exit        */
/*--------------------------------------------------------------------*/

PROGRAM_ERROR:

  'VMFCLEAR'                                      /* Clear The Screen */

  Call Diag 8, 'SCREEN VMOUT DEF'                   /* Default Colors */

  Say ' '

  Call Diag 8, 'SCREEN VMOUT RED'
  Say HI || '    ERROR:' || LO
  Call Diag 8, 'SCREEN VMOUT DEF'

  Say ' '
  Say '     An error has occurred with the' || HI || EVENT || LO || ,
      'program, please'
  Say '     contact the Manager of User Services for further as-'
  Say '     sistance. Please retain a copy of the' || HI || SASLOG || ,
      LO || 'file.'
  Say ; Say

  Call Diag 8, 'SCREEN VMOUT' COLOR ATTR    /* Return Original Colors */

  'EXEC SYSMSG ON ( NOMSG'            /* Turn On The System Messaging */

Exit SYSRC