<<

A New Approach to Creating Full-Screen Menu-Driven Systems for the SAS® System under CMS

Jeffrey L. Fowler, Boeing Services

ABSTRACT unprotected areas on the screen. Panels actually permit the user to edit a SAS data set. While many approaches have been used in writing full-screen, menu-driven SAS" systems for CMS, SHOWPAN was written for a menu-driven report none proved completely satisfactory for our system in which the users update SAS data sets by purposes. Therefore, we wrote our own Display selecting different menu options and then produce Manager: SHOWPAN. reports by making other selections. This report system, AMARS (Acquisition Management and SHOWPAN is a SAS macro which displays menus Reporting System), displays close to 200 panels and and data entry panels from within SAS using the menus. It is written entirely in SAS, except for the CMS full screen editor, XEDIT. It will work in any execs and XEDIT macros used by SAS 82 or version 5 system running under CMS SHOWPAN to format the screen. The SAS macro Release 4. It was developed in an attempt to correct language is used to selectively include and execute some of the problems encountered with other other SAS code based on menu selections. display managers. These problems are: At the time AMARS was being developed, our • The data set being edited must exist prior to installation was using SAS 82.3. The screens were displaying the screen. being displayed using a SASIFSp® procedure called • Code must be written for each screen to edit PROC FSEDlT. The FSEDIT procedure allows SAS check fields and to validate responses. data sets to be edited on screens which the • Response time is too slow. programmer can fonnat however he desires. • The screens take too much time to design. • Calculations cannot be done without This technique was OK for panels, but extremely returning to SAS. cumbersum for menus. Too much code was being written to build data sets in order to display a menu, This paper describes how SHOWPAN addresses then after returning from the menu, to validate the these and other problems and explains its internal user's selection. What we needed was a way of workings. validating the ",ser's selection WHILE STILL ON THE SCREEN, and returning the selection to SAS in the form of a macro variable. INTRODUCTION

Before beginning, two terms that are used MENU DISPLAY frequently in this paper must be defined: MENU and PANEL. A menu is a screen which prompts the Our first attempt at a solution was a very user to a selection. A panel is a screen on version ofSHOWPAN which displayed only menus. which the user is required to enter data in certain The menus were simply CMS files created with XEDIT. SHOWPAN would XEDIT the CMS file,

1296 showing all of the lines except the last one to the (1) How does DOWNLOAD know which fields user. As soon as the user entered a response, his are being displayed on the panel so it can input was compared to the range of permissable download them from the SAS data set? responses contained in the last line of the file. If a (2) How does DISPLAY know where on the panel match was found, SHOWPAN returned control to these fields are shown? the SAS program, passing it the item selected in the program stack. Otherwise, an error message was The answer to both these questions is in the way the displayed and the user had to reenter his selection. panels are designed. Figure 2 shows a sample Figure 1 shows a sample menu as might be panel, illustrating the syntax we decided was the displayed with our current version of SHOWPAN. easiest to use. Briefly, each panel is divided into It is very similar to the earliest prototypes. three sections. The first, called the Panel section, contains the body of the panel. That is, the part This menu-display system worked so well and saved seen by the user. This section can contain both so much time, both in coding and in response time, constant information, such as column headers or that Iwas asked to determine the feasibility of instructions; and variable information, which are displaying data entry panels using the same the values being edited on the SAS data set. The technique. Following is my solution. variable fields are identified by "@". These are the only fields, other than the command line, where the user is permitted to type. These fields can be PANEL DISPLAY reached by using the keyboard tab keys.

SHOWP AN panels essentially let users XEDIT SAS The Panel section must start with the keyword data sets. It first invokes a CMS REXX exec -­ PANELNAME and end with ENDPANEL. A name DOWNLOAD -- which looks at the panel about to be to the panel may be supplied following the displayed and determines which fields from the SAS PANELNAME statement. This name will be data set are being displayed on this screen. displayed in the upper right corner of the panel at DOWNLOAD then creates a SAS macro to display time. Basically, SHOWPAN displays every download these fields from the SAS data set to a flat line between PANELNAME and ENDPANEL on CMS file, and returns control to SHOWPAN. the terminal screen, using the XEDIT SET SHOWPAN executes the macro, creating the CMS RESERVED command. The "@" fields are the only file. The panel is then displayed with XEDIT, under places on the screen, other than the command line, control of a REXX XEDIT macro called DISPLAY where the user is permitted to type. These fields which reads in the flat CMS file and displays each appear as underscores at display time. fields in its proper place on the screen. The input fields (where the "@" are) are created by When the user is finished entering or modifying using control characters in the SET RESERVED data on the panel, the process is reversed. command. These control characters are used to tell DISPLAY XEDIT writes another SAS macro to read XEDITthat: in the flat CMS file as input and (re)create the original SAS data set. Control then returns to • The following field is unprotected, ie: it can SHOWPAN which executes the macro, rebuilding be typed over. the SAS data set. • The following field is protected. • The following field is to be displayed in one of Two immediate questions come to mind about this 8 colors. process: • The following field is to have extended highlighting. It can be made to blink, to be

1297 underligned, to be displayed in reverse (alphanumeric, convert to upper case); N viedeo, and so on. (numeric, no decimal); Nx (numeric, round to • The following field is to be displayed x decimal places). SHOWPAN issues an highlighted (high intensity). error message when the user tries to enter an • The following field is to be displayed not alpha in a numeric field and vice-versa. It highlighted (nonnal intensity). automatically converts the case if required • The following field is invisible. and rounds any number entered to the desired number of decimal places. Infonnation about these commands can be obtained • Field Attribute. Pennissable values: N (non­ from the IBM System Product Editor Command and protected); P (protected); I (invisible). If the Macro Reference. field is protected, the user is unable to alter its contents (the cursor will not even go SHOWPAN determines the position of the "@" there). If non-protected, the user may alter fields and inserts the proper control characters to its contents. If invisible, it is non-protected protect or unprotect each field on the screen. but anything being typed in is not displayed. Numbers are right-justified prior to display. This is sometimes desired for clssified Alphanumeric fields are left exactly where they are information such as passwords. typed, so as to preserve leading blanks. • Permissable Values. SHOWPAN will not allow the user to enter any value in this field The second section, called the Field Definitions other than that specified. These values may section, is the section which describes all the be expressed as a range, ttA" - "Z"; as one or variable fields being displayed on the panel. The more explicit values, "A''', lIB", tIC"; or, to fields must be described in the order in which they allow anything to be entered in this field, as appear on the screen, going from left to right and an asterisk. This field must be enclosed in top to bottom. In this section, the field parenthesis. Alpha values must be specified characteristics are established. Fields can be between quotes, either single or double. required/not required, protected/not protected, Numeric values must not be enclosed in numeric/alphanumeric. You may also specify quotes. In this case, the only value the user pennissable values for the field in this section. The may enter for field TEAM is REDSKINS. Field Definitions section starts with the word FIELDDEF and ends with ENDDEF. The third section, which is optional, is called the Paneliogic section. This section lets the Examine the first field definition in figure 2. The programmer do calculations on the screen without definition is divided into 5 parts: returning to SAS. It starts with the word PANELLOGIC and ends with the word • SAS Variable Name. This field contsins the ENDLOGIC. It must be written in REXX. It is name of the variable as it is identified on the executed by SHOWPAN when the user tries to SAS data set being edited, in this case leave the screen. In this example, the TEAM. PANELLOGIC section calculates the winning • RequiredINot Required. Permissable values: percentage for the field WINPCT by dividing the R or N. If it is R, the user MUST enter number in the field WINS by 16, multiplying that something in this field or SHOWPAN will total by 100, and rounding to two decimals. issue an error message. If not, no entry is required. • Variable Type. Permissable values: A (alphanumeric, mixed case); AU

1298 HOW DOES rrWORK? • Panels and menus are now "COMPILED". A REXX routine called CMPSCRN which Unfortunately, to adequately explain the internal checks panels and menus for syntax errors workings of SHOWPAN's panel dislplay would and initializes variables for SHOWPAN. require too much space. However, following figure These variables are written to a CMS file 2 is a scaled-down version of SHOWPAN, called having the same file name as the panel, with SHOWMEN, for displaying menus. This code is a file type of PTEXT. This routine is run by accompanied by a sample menu which is not unlike the programmer interactively once he has figure 1, and a REXX EXEC, DOMENU, to format finished creating the screen. It cut down on the screen. It will run on any CMS Release 4 system display time tremendously. running SAS version 82.3 or later. With very few • Users can type ahead responses to menus and modifications it can also be made to run under CMS panels not yet displayed. This feature Release 3. eliminates a lot of unnecessary processing and allows users familiar with the system to take "shortcuts" directly to the desired option SUMMARY without having to see each screen in sequence. Panels and menus are quick and simple to design. • A global macro variable -- &RC -- is set by A menu can generally be created and "hooked up" SHOWPAN and can be used to determine if within 10 minutes. A panel takes a little longer as any changes were made to the data set being each field being displayed must be defined. edited. Using this variable saves a lot of However, an average-sized panel usually can be unnecessary processing. created and installed within a half-hour. Once a • Variable information, such as today's date or menu or panel has been created, it can be displayed the userid, can be displayed on both panels with one of these statementa: and menus without storing them on SAS data sets. %SHOWPAN(TEST,MENU); '* To display a menu. */ Currently, SHOWPAN consists of 13 separate SAS %SHOWPAN(TEST,PANEL,sasfn sasft); '* To macros, REXX execs, and XEDIT macros; and display a panel. *' contains 2,166 lines of code. It supports the following panel commands: The first parameter is the file name of the menu being displayed. The only acceptable values for the • CANCEL -- Leave screen, cancel any changes second are MENU or PANEL. For panels only, the made to the data set being edited. third parameter is the CMS file name and file type • RETURN -- Leave screen, update SAS data of the SAS data set being edited. set being edited with changes (if necessary). • ADD -- Add an observation to the data set Some of the features and additions to our current being edited (will display a screen with all production version ofSHOWPAN are: variable fields being blank). • DELETE -- Delete observation being • Panels can create SAS data sets that do not displayed. exist. • RUN -- Execute PANELLOGIC section. The • Panels can have more than one page. P ANELLOGIC section will also be executed • More than one observation can be edited per if the user enters RETURN. page. • KEY -- Define one or more key fields for LOCATE command. SHOWP AN will prompt

1299 the user to place the cursor on any field he PANELNAME TEST

wants used as the locate key, and depress the .U THIS IS A$AMPLE MENU •••

enter key. As many keys can be defined as Select One: there are fields. 1 .. 1am ill Redskins fan • LOCATE·· Tells SHOWPAN to locate the I am ill fan of any team who plays the Cowboys ., Idonotlikefootball observation having the desired values in the P Return to Previous Menu key field(s) and display it on the screen. M Return to Main Menu • n (where n is a positive integer) .. Display • Logoff record number n on the screen. IT n is larger END PANEL FIELDDEF than the size of the file being edited, the last ('1'. '2', '3', 'p', 'M', 'l') ENDDEF observation is displayed. • Sn (where n is a positive integer) .. Display Figure 1, sample menu. screen n of current observation. Used only

when more than one screen is needed per PANELNAME PANEL1

observation. If n exceeds the total number of Date: I/.I/.I/.(tl/.(I/.

screens, the last one is displayed. Name of favorite football team: @@@@@@@@ Name of favorite football player: @@@@@@@@@@@@@@@@

WINS LOSSES Expected wonllost record: @@ @@ CONCLUSION Winning percentage: @@@@@@

ENDPANEL SHOWPAN started out as a small, simple, menu FIELDDEF display routine, probably totalling less than 400 .. SAS variable requiredl variable field permissable name not required type attribute values lines of code. When it was found how quickly and TEAM R AU N (,REDSKINS") easily the menus could be written and installed as PLAYER R A N (') WINS R A N (0-16) well as how much faster they were to display than LOSSES R N N (0-16) WINPCT N N2 (') other methods that had been tried (typically two to ENDDEF three times faster) it was expanded to allow for the PANELLOGIC WINPCT (WINS/16)* 100 editing of SAS data sets. For many applications this WINPCT = FORMAT(WINPCT,3,2) ENDLOGIC may not be necessary, as PROC FSEDIT may provide all the screen formatting capabilities Figure 2. sample panel. required.

Many details have purposely been left out of this 1* *** *** * *** *** * **** * .. * * * .... * .... *** ***** .... ****** *** ******** * ... f 1* Purpose: Displaysfull..screen menus from within SAS, *f paper in an attempt to make 'it as concise as 1* returns selection in macro variable &ANS. If a problem ,of f* was encountered during display, &ANSwili be null. .of possible. Hopefully, however, enough information f* calling syntax: "f f* %SHOWMEN(menuname); "f has been provided to at least give you some ideas ,.. Where: ,of about how SAS and the SAS macro language can be ,.. menuname - IstheCMS file name of the menu you *1 ,.. wish to display. The file type must be ,of used in conjunction with other laguages and ,.. MENU. ,of ,.. Author: Jeff Fowler *f features to allow you to come up ,.. Boeing Computer Services "f ,.. * *** * *** **** * ** * * .... * * * .. * ** * * .. * ***t*"* * * * *** *** *t* *tt* ,ott_, with creative solutions to almost any problem. %MACRO SHOWMEN (MNUNAM); %GLOBALANS; %CMS XEDIT NULL FILE A (PROFILE DOMENU) &MNUNAM; %IF(&SYSRC =0) %THEN %INPUT ANS; %ELSE %LET ANS = ); RUN; %MEND SHOWMEN;

SAS and SAS/FSP are registered trademarks of SAS Institute Inc., Cary, NC, USA.

1300 PANELNAME TEST f* Build screen. */

*** THIS IS A SAMPLE MENU *** DO A = 1 TO LSCREEN.1 SELECT Select One: WHEN A = 1 THEN 'SET RESERVED 1 NOH' CMDLlNE WHEN A < = RESLlN.OTHEN 'SET RESERVED' A 'NOH' RESLINA Create Transaction OTHERWISE 'SET RESERVED' A 'NOH' .. Modify Transaction END Delete Transaction ENDA 4 CreatelDisplay Report S Print Report f* Continue to display menu until correct response is give. *1

P Return to Previous Menu ANS =" M = Return to Main Menu DOA", 1 L .. Logoff 'CURSOR SCREEN 1 7 PRIORITY SO' 'READ ALL TAG' ENOPANEL PARSE UPPER PULL KEY .. ANS FIELODEF IF KEY -= 'RES' THEN ITERATE A 1214SPML IF FINO(RETVAL,ANS) -,. 0 THEN LEAVE A ENOOEF 'EMSG Invalid selection:' ANS 'CURSOR SCREEN 1 1 PRIORITY 60' END 'OESBUF' PUSHANS 'QQUIT' EXIT f* ****** **** * *** ** *** ***** ** *** ***** .. ** * * ** * *** *** * .... * .... *""*1 f* DOMENU XEDIT *1 1* Read panel into RESLIN array 'till we hit an ENDPANEL statement. *' PARSE ARG '(' T MENU f* * .. *** .... ** .. * .. **** .. **** •• * * ...... * ...... ** ** * * *** ** ...... "*, GETPAN: f* Read in menu */ DO LPT = LPT TO L1NE.O IF lINE.LPT = 'ENDPANEL' THEN RETURN 'EXECIO * DISKR' MENU NAME 'MENU * (FINIS STRIP STEM LINE: RESL1N.O '" RESL1N.O + 1 IF RC - = 0 THEN CALL ERR 'Problem reading' MENUNAME 'menu.', RC J = RESUN.O RESUN.J so LINE.LPT f* Initialize variables and arrays. *1 END CALL ERR 'Error: no ENDPANEL statement found.', 99 RESLIN. 1* .. ** .... * •• * .. **** ... ********** ...... * ...... *.* * *** ** * * *** *** *** *"*' RESLlN.O • 0 1* Get permissable responses to this menu. *' LPT • 0 1* *********** *** ******** ********** *** *** * *** *** * * ** ...... *"* I PNLNAME GETDEFS: BEGPAN 0 DO LPT .. LPT TO L1NE.O BEGDEF 0 IF LlNE.LPT = 'ENDDEF' THEN RETURN RETVAL L1NE.LPT = STRIP(LlNE.LPT, 'B') RETVAL _ RETVAL LINE.LPT DO A = 1 WHILE LTP - = LlNE.O END LPT ",LPT+l CALL ERR 'Error: no ENDPANEL statement found.', 99 CMD = WORD (LlNE.LPT, 1) 1* *** .. **.* ***** *** ** * ** .. ** ** * ... *** ..... * **** *** .... * * **** ** * *** *-, SELECT 1* Display error message, quit menu, and exit. *1 WHEN CMD = 'PANELNAME' THEN DO 1* * .. *** * .. *** ******* .. ****** *** .. * * .. * ****** * .... * .... * * ..... * .. **** * "* I PNLNAME '" '('USUBWORO(LINE.A,2)U')' ERR: BEGPAN .. 1 PARSE ARG MSG, RTN CALLGETPAN SAYMSG END 'QQU1T' WHEN CMO .. 'FIELDOEF'THEN DO EXIT BEGOEF = 1 CALLGETDEFS END OTHERWISE NOP END ENOA

SELECT WHEN BEGPAN = 0 THEN CALL ERR 'Error: no PANELNAME statement found:, 99 WHEN BEGDEF = OTHEN CALL ERR 'Error: no FIELDDEF statement found.'. 99 OTHERWISE NOP END The author can be contocted for further information f* Build command Line. *1 at the following address: NUM .. 64 - LENGTH(PNLNAME) CMOLINE = '", '" .. >% + %-'IICOPIES(' , ,NUM) II PNLNAME 'SET CTLCHAR % ESCAPE' 'SETCTLCHAR + NOPROTECTHIGH' Jeffrey Fowler 'SETCTLCHAR - PROTECTNOHIGH' 'SETMSGLlNE ON 1 10' Boeing Computer Services 'SET CMOLINE OFF' 'SET ENTER' M,S.CV-31 'EXTRACT/LSCREENf 7980 Boeing Court Vienna, VA 22180

1301 1987 SASware Ballof Results

1. SAse Software: 453.0 4 18 store value labels from PROe FORMAT as part of the SAS data set

*** General *** 453.0 4 19 store array definition with data set Rank Count 110.0 35 20 inerease label length from 40 to 80 55.0 ability to display CUI"l"ent BY value in eharacter$ title, suppressing default BY line 241.5 ,. 21 make the SAS System a relational data 167.5 25 visual data management system for ba$e management system capturing, managing, and replaying any kind of pictorial input, such as color graphics, text, computer programs, slide-snd-text *** DATA Step *** presentations, or video input 18.0 83 22 a cross-r-eference facility to produee an index of all variables, their formats, and 102.5 37 3 provide page number re,et option so on, referenced in a DATA step

341.5 10 support overprinting or boJdhce fOI" TITLE 167.5 25 23 ability to update a SAS data $et in a DATA and FOOTNOTE statements in nongraphics $tep Without ereating an additional data batch procedures "t

B7.S 42 option to omit carriage control charaden 453.0 4 24 table look-up function or reeoding facility

223.5 20 allow access to different types of data 409.0 6 25 ability to cheek status of SAS system bases or files with a OATA"'option, SET options in programming statements statement, Or INFILE statement 304.5 13 26 warning rather than er-ror for- duplication 453.0 4 save information on how a SAS data $et halO of variable$ within a single DROP or KEEP been $orted and give aecen to the statement infor-matlon through the DATA step 503.0 27 new JOIN statement like MERGE, but 409.0 system option that allow$ expr-ession$ producing all combinations of observations involving compar-ison$ with mining values within BY group to equate to a mining value, e.g. x=age>5O 1 sex"1; results in' a mining value if either- var-Iable i$ missing 409.0 28 NEXT .var-iable: the value in the next occurrence of the variable 503.0 2 9 allow char-aeter- var-iables to be longer­ (up to 32K) 241.5 18 29 allow variable Ii$ts in RENAME statement: RENAME X1-XlO"'Yl-Y10; 409.0 10 sY$tem option SASUSER=libref, which can $pecify an alr-eady defined library to be 167.5 25 30 allow array name, in all DATA step used for- SASUSER library statements

536.0 11 ability to r-emain in SAS session after 195.5 22 31 support exact rational arithmetic and high common er-rors such as running out of disk precision arithmetic space or- memor-y

9.0 109 32 Implement a LEAVE statement for exiting a 110.0 35 12 alia$es for- var-iable name, (multiple DQ group, allowing execution to continue var-table names for the ,ame value) with the statement follOWing the END $tate­ ment

64.5 53 13 provide capability for variable name$ to be 40 character$ 78.5 47 33 ability to determine the number of ObSel"Vations in a data set within a macro

o 14 provide a syntax $can without opening exter-nal file$ 195.5 22 34 issue a waming message when preci$ion is lost when a LENGTH statement is used

536.0 15 ORDER $tatement for reordering variables in a SAS data set 241.5 1. 35 option to convert all numer-ic missing values to zero or ,pecified value *** SAS Data Sets *** 266.5 16 36 allow for- a ,ystem option $imilar 4.0 126 16 ability to eompren and deeompreu data to a 'fuu' option that automatically values in large SAS data sats rounds all numbers when doing comparisons to a certain precision

304.5 13 17 generations of SAS data sets with concept of (+1) for- next, (0) for current, (-1) for 478.5 3 37 print a NOTE when a MERGE statement is U$ed last, (-2) for- next-to-last, and so forth without a cor-r-esponding BY $tatement

1302