4. CA MICS Facilities › 4.5 User-defined Informats and Formats › 4.5.2 Creating Unit-level Catalog Entries
4.5.2 Creating Unit-level Catalog Entries
A standard job is available to update the USERFMT1 and
USERFMT2 catalogs in prefix.MICS.MUOLIB. This job, USERFMTU,
is automatically generated in prefix.MICS.CNTL. The input to
this catalog update job is the following members of
prefix.MICS.USER.SOURCE:
USERFMT1 - Adds and updates entries in catalog USERFMT1
USERFMT2 - Adds and updates entries in catalog USERFMT2
The only code that needs to be entered in these members is
the INVALUE, VALUE, and/or PICTURE statements necessary to
generate your formats. Please refer to the SAS Procedures
Guide for complete syntax rules on coding these input
statements to PROC FORMAT. Any number of these statements
can be coded in each member. All formats defined in this
member will be updated each time the USERFMTU job is
executed. An invocation of PROC FORMAT with output to the
appropriate catalog is automatically invoked and need not be
coded in the input member.
If you need to perform more complicated processing, such as a
DATA step that reads an external file and then generates a
format, that code can either be coded in these members or
%INCLUDEd from standard CA MICS libraries or private data
sets. The only requirement is that you code your PROC FORMAT
invocation statements in the following format:
PROC FORMAT LIBRARY=MUOLIB.USERFMTn;
...INVALUE, VALUE, and/or PICTURE statements...
RUN;
The following examples show input methods that can be used in
these members.
Example 1--Coding INVALUE, VALUE, and PICTURE statements to
be processed by PROC FORMAT.
INVALUE CHECK
'1'-'4'=_SAME_
'99' =.
OTHER =_ERROR_;
PICTURE DAYS
01-31='99'
OTHER='99 - Illegal day value';
VALUE ABC
1='A'
2='B'
3='C';
VALUE $TAPES
'0300'-'032F'='TAPE'
'0400'-'043F'='CART'
'0800'-'08FF'='SILO'
OTHER='????';
Example 2--Determining the value of one SAS variable based on
the value of another SAS variable.
A SAS format can also be used to determine the value of one
SAS variable based on the value of another SAS variable. In
most simple cases, a SAS DATA step can be coded with a series
of IF/THEN/ELSE statements to achieve this result, as shown
in the following example.
IF USER =: 'PR' THEN TSOACT1 = 'PR25';
ELSE IF USER =: 'TS' THEN TSOACT1 = 'TS01';
ELSE IF USER =: 'PL' THEN TSOACT1 = 'PL15';
ELSE IF USER =: 'RX' THEN TSOACT1 = 'RX25';
ELSE TSOACT1 = '*UNKNOWN*';
If the list of possible values for USER were large or if the
possible values changed frequently, it would be more
effective and efficient to use a SAS format to assign the
value of TSOACT1 based on the first two characters found in
the USER variable. When using a SAS format to perform a
table search, you do not have to modify your exit routine.
You need only replace the SAS format, minimizing coding or
syntax errors.
For example, a SAS format could be written to translate a
user's logon identifier to a group name for assigning TSOACT1
values. The following code can be used to input a sequential
file that contains valid logon identifier prefix values to
use for a table search of expected values. If the value
present in the USER variable is one that is unknown to the
table, a value of "*UNKNOWN*" will be returned from the PUT
function when performing the table search in the TSO Account
Code Exit Routine (TSOACRT).
The following example shows the SAS format $UIDGRPS being
saved in the USERFMT2 catalog in prefix.MICS.MUOLIB each time
the job in prefix.MICS.CNTL(USERFMTU) was executed. This
code could be added to prefix.MICS.USER.SOURCE(USERFMT2).
The job in prefix.MICS.CNTL(USERFMTU) would need to be rerun
whenever the list of ID prefix values and group name values
changes.
/* ALLOCATE THE INPUT DATA SET */
FILENAME INPUT 'user.input.ids' DISP=SHR;
DATA _NULL_;
LENGTH ID $2 GROUP $10 ;
INFILE INPUT END=EOF; /* INPUT SEQUENTIAL FILE */
FILE FT15F001; /* USE TEMP WORK FILE */
PUT "PROC FORMAT LIBRARY=MUOLIB.USERFMT2;" /
"VALUE $UIDGRPS ";
DO UNTIL(EOF);
/* TABLE LOOK-UP VALUES ARE IN COLUMNS 1-2 AND 10-19 */
INPUT @01 ID $2. @10 GROUP $10. ;
PUT "'" ID "' = '" GROUP "'";
END;
PUT "OTHER = '*UNKNOWN*';";
STOP;
RUN;
%INCLUDE FT15F001; /*INCLUDE THE GENERATED PROC FORMAT */
RUN;
An alternate method of performing the same process is to use
the CNTLIN option of PROC FORMAT. Notice that the format
name variable FMTNAME does not have the $ in the retained
value. The fact that this is a character format is defined
by setting the format type variable, TYPE, to C. The format
is still referenced as $UIDGRPS in a PUT statement.
/* ALLOCATE THE INPUT DATA SET */
FILENAME INPUT 'user.input.ids' DISP=SHR;
DATA WORK.CNTLIN;
RETAIN FMTNAME 'UIDGRPS' /* NAME OF FORMAT TO BE GEN'D */
TYPE 'C' /* THIS IS A CHARACTER FORMAT */
HLO ' ' /* FOR USE WITH OTHER= OPTIONS*/
;
INFILE INPUT END=EOF; /* INPUT SEQUENTIAL FILE */
DO UNTIL(EOF);
/* LOOK-UP VALUES ARE IN THE FIRST NON-BLANK COLUMN */
INPUT @01 START $2. @10 LABEL $10. ;
END=START; /* START/END OF RANGE ARE SAME */
OUTPUT;
END;
START='**OTHER**'; /* GENERATE AN OTHER= VALUE */
END=START;
HLO='O';
LABEL='*UNKNOWN*';
OUTPUT;
STOP;
RUN;
/* GENERATE THE FORMAT */
PROC FORMAT CNTLIN=WORK.CNTLIN
LIBRARY=MCOLIB.USERFMT2 PRINT;
RUN;
FILENAME INPUT CLEAR; /* FREE THE INPUT DATA SET */
If the code in the above example was stored in a private
partitioned data set, it could be added to the USERFMTU
update process as follows:
%INCLUDE 'your.private.pds(member)';
SAS will dynamically allocate, read, and free the data set
for you.
If the code in the above example were stored in another
member of prefix.MICS.USER.SOURCE, it could be added to the
USERFMTU update process as follows:
%INCLUDE USOURCE(member);
The SAS code above assumes that the sequential file contains
the table look-up entries in columns 1 and 2 and the
associated Group Names in columns 10 through 19. You should
change the INPUT statement to identify the columns that
contain the desired values.
A sample CA MICS TSOACRT routine that uses the format
$UIDGRPS is illustrated in the sample SAS code below.
IF ROUTINE='DYTSOFMT' THEN DO;
TSOACT1 = PUT(SUBSTR(USER,1,2),$UIDGRPS.);
... other SAS statements ...
END;
The table $UIDGRPS is searched for the value contained in the
first two positions of the USER variable and the search
result is placed in the TSOACT1 variable.