Appendix 1 Application Stream Installation Allocate Files Allocate the following required files if they do not exist: - a location/library for DATA step source files and MFC code. - a SAS library to contain stored programs. - an external file. This is for the audit trail report to be easily seen when submitting SAS. SASLOG or SASLIST can be used. "Appendix I" contains a sample stream where a separate file is used during development to isolate the audit trail. As streams near production status, SASLOG is used. See the MFCINIT code in "Appendix II.". - an external WORK file. This is used once at the stream's start to hold output from processing the source library directory, and later on to hold a copy of the DATA step source code before the audit trail statements are added. Only one file is needed because the records are the same fixed length for both uses. You may need a second file. Copy and Modify Code Copy each MFC file (see "Appendix II") into a file in your DATA step source library. There are comments throughout for potential areas for change. The lines of code with a HOST comment require review and probable changes for non-MVS hosts. You may want to change the SOURCE and SOURCE2 SAS options in %MFCDRIVR to make MFC code visible when testing MFC. Consider the MPRINT and SYMBOLGEN options for any debugging. All hosts If your stream produces a WORK data set named MFCTRDAT, you will change either your data set name or the MFC's. If your stream uses any of the &MFC macro variables in Table 3, make variable name changes to avoid 'stepping on' the &MFC values. Likely changes will be the text for your values for the four &MFCXXREF macro variables in the MFCINIT series of files. There is an optional redirect capability. In MFC context, a REDIRECT might be needed when running programs using the RUNCOMP choice. If you want to redirect, you can use a %LET statement in the stream to assign the value for the redirect text. For example, to read data set NEWNAME instead of INTOSAMP, the %LET statement is added prior to the macro invocation: %let mfcredir=redirect input intosamp=newname; %mfcdrivr(mfcchpgm=mfcsamp2,mfcch=runcomp); The final bit of logic in the RUNCOMP section of %MFCDRIVR assigns a null value to &MFCREDIR so that you only have to be concerned about using the %LET statement prior to invoking the macro. MVS host Be sure to check the values for the S= and S2= options to avoid truncation or contamination of your source code due to line numbers. If your source files use variable length records please see "Variable length Records" in the section "Non-MVS Hosts." If you use JCL to assign a ddname/fileref and a data set name rather than using FILENAME and LIBNAME statements, you may also want to automatically assign the physical names via the JFCB= option. Affected variables are &MFCSRLIB and &MFCRULIB. Comments are contained in the MFCAUDST, MFCINITA, MFCGETNA, and MFCLIBNA files. About 15 lines of code are affected. Non-MVS hosts This primer concerning an MVS source library and the associated MFC and SAS syntax may help set the stage for some of your changes. Pertinent lines from application stream initialization in "Appendix I" are used as an example. %let mfcsrref=fileref; %let mfcsrlib=data-set-name; filename &mfcsrref "&mfcsrlib" host-specific-options; fileref source, overall name pointing to an aggregate storage location. data-set-name hilevel.sas.applica is the MVS data set name assigned to the aggregate storage location, a source library with a partitioned organization. Think of it as a combined location and directory having underlying individual files. The following are example statements to bring a source code file into a stream: %include source(mfcsamp1); %include &mfcsrref(&mfcchpgm); /* with macro variables */ mfcsamp1 is an example file within hilevel.sas.applica. You assign the value to &mfcchpgm in the stream. MFC code assigns HILEVEL.SAS.APPLICA(MFCSAMP1) to &mfcsrlbf for reporting. MFC FILE and INFILE statements are similar. 1) %INCLUDE, FILE, and INFILE Statements For directory based systems such as PC DOS, WINDOWS, OS/2(r), VMS, and UNIX, consider the following example: %include 'physical file name'; This leads to the statement with no macro variables: %include "c:\source\mfcsamp1.txt"; This statement contains location, directory, file, and extension names. Pick a standard value for the extension name of your source code files, and assign a macro variable (assume &mfcext) to the MFCINITA code. The affected statements are %let mfcsrref=c:\source\; %let mfcext=txt; mfcext is added to the %GLOBAL statement in MFCINIT. The following stream MFC statement invokes %MFCDRIVR: %mfcdrivr(mfcchpgm=mfcsamp1,mfcch=sourced); Then, the following revised statement in the MFCDRIVR macro definition source code file resolves to the needed %INCLUDE: %include "&mfcsrref.&mfcchpgm..&mfcext"; FILE and INFILE statements will also need changes. Variable Length Records For MFC processing of variable length records on your host, FILE and INFILE statements will change in other ways, as well as INPUT and PUT statements. When reading files, consider the PAD option to avoid missing data. Three MFC DATA steps are read and write records to files containing DATA step source lines. Consider reviewing the $VARYING, LRECL, and RECFM options to determine the best approach on your host. The affected MFC code files in "Appendix II" are MFCAUDST First DATA step reads the source file to be compiled. writes an exact copy to an external WORK file. Second DATA step reads external copy of source. writes updated DATA step source to source library file. (All input lines are written with no change. Add lines to produce audit trail.) MFCEDITS reads the source to be compiled, and writes a report file. MFCRSTRS reads external copy of source file, and writes it with no change to source library file. MFCTRDAT reads source library directory. Creating the MFCTRDAT audit trail data set Remove the SOURCE procedure from the MFCTRDAT code. Determine the data content of your directory from SAS host manual, and select the fields you want to appear in the audit trail. Modify the DATA step to read your source library directory, and make the SAS data set of audit trail variables. Modify the PUT statements in the MFCAUDST code that add the audit trail-producing statements. Modify Your Stream and DATA Steps 1. Add a %INCLUDE statement at the beginning of the stream for the MFCINITA file. 2. Move the DATA step source including the RUN statement to its own file in the DATA step source library. Insert the &MFCCOMPI macro variable just to the left of the semicolon ending the DATA statement. MFC requires that: the rest of this line is blank, so the automatically added statements do not disrupt existing code. NO text is to the left of DATA on the line where the DATA statement starts, and the RUN statement is the only text in the last line of the DATA step source code file. One valid examples is data outnam1 outnam2 &mfccompi; your statements run; Another example is data outnam3 (options) &mfccompi; your statements run; 3. Replace the stream DATA step source with the model statements in the MFCCMPL file. Copy this file with your text editor, and complete the DATA step name and the MFC choice. /* data step name MFC choice */ %mfcdrivr(mfcchpgm=mfcsamp2,mfcch=sourced); /* driver macro */ INDCOMP Installation 1. Allocate a source library and copy the code in "Appendix 5: Independent Compile Library Source Files" into its files. A new library is suggested, but it only has to be a different source library from the one containing your application stream DATA step source. 2. Make the same kinds of host changes as the stream MFC. 3. Required file references in MFCINITC are the same as for an application stream. Additional librefs which may be needed are for permanent SAS libraries FROM YOUR STREAM containing data sets needed as input for the DATA step source to be compiled. 4. Copy the MFCCMODL statements into a file in the INDCOMP library for each DATA step to be compiled. The INDCOMP file name will be the same as in the application source library. The INDCOMP file DOES NOT DUPLICATE the source code, rather it contains code needed to simulate the DATA step being in a stream. (MFCSAMP1 and MFCSAMP2 are completed examples.) A. If your DATA step uses &MACRO variables and the values are assigned in the stream prior to the DATA step, you can use a %LET statement in the INDCOMP file. B. SAS requires that all input SAS data sets be available for a compile. If your DATA step is reading a permanent SAS data set by a statement such as set sasspace.sasfilin, then INDCOMP file code is not required. Extra code will be needed to re-create WORK data sets. If you do not want to change them to permanent librefs, you have three choices. 1. Create a data set within the INDCOMP file. If your step reads a data set called TWOVAR, you could add the following: data twovar; var1=3; var2='abcde'; run; 2. For a more complex WORK data set called MANYVAR you can transfer it from the application with these steps: a. Create a permanent SAS library; point to it with a libref such as SASCMPL in your application stream. In a separate DATA step separate from your main functionality, capture one record with in the following: data sascmpl.manyvar; set manyvar (obs=1); run; b. In your INDCOMP file re-create the WORK data set: data manyvar; set sascmpl.manyvar; run; 3. If 1 2 are too much trouble, or the content of your WORK data sets in the application stream changes frequently for the DATA step being compiled, forget INDCOMP and use your stream to compile this particular DATA step. MFC eases the process. You can always insert ENDSAS statements to keep unaffected downstream processing from running.