LASR Procedure

Example 9: Working with User-Defined Formats and the FMTLIBXML= Option

Details

As explained in the previous example, the LASR procedure can use any format so long as the format is in the format catalog search order. The procedure automatically converts the format information to XML and transfers it to the server with the data. However, if the same formats are used many times, it is more efficient to convert the formats to XML manually and use the FMTLIBXML= option.
You can use the FORMAT procedure to write formats to an XML fileref. Then, you can reference the fileref in the FMTLIBXML= option each time you use the LASR procedure to load tables. This improves performance because the conversion to XML occurs once rather than each time LASR procedure transfers the data.
Formats are created with the FORMAT procedure. The following SAS statements show a simple example of creating a format and using the XML fileref in the LASR procedure.

Program

proc format library=gendrfmt;
     value $gender   'M'='Male'        'F'='Female';
run;

options fmtsearch=(gendrfmt); 1

filename fmtxml 'genderfmt.xml';
libname  fmtxml XML92 xmltype=sasfmt tagset=tagsets.XMLsuv;

proc format library=gendrfmt cntlout=fmtxml.allfmts; 2
run;

proc lasr add data=sashelp.class fmtlibxml=fmtxml; 3

    format sex $gender.; 4

    performance host="grid001.example.com" 
        install="/opt/TKGrid"
        nodes=ALL;
run;

Program Description

  1. The user-defined formats are available to the LASR procedure because they are added to the format catalog search order.
  2. An XML stream for the formats in the file GenderFmt.xml is associated with the file reference FmtXml. The formats are converted to XML and stored in the file.
  3. The file reference FmtXml is used with the FMTLIBXML= option in the PROC LASR statement. For subsequent uses of the LASR procedure, using the FMTLIBXML= option to reference the fileref is efficient because the formats are already converted to XML.
  4. The $gender. format information is transferred to the server in an XML stream and associated with the variable that is named sex. However, the format must be available to the SAS session that runs the LASR procedure.