Exporting to SAS Transport Format Library Program

Export SAS Transport Format Library Program

  1. Go to File|Export Interviews.
  2. Select SAS Format Library Program (.XPT) from the Save as type drop-down box.

Images\WM_ExportSASFormat.gif

  1. Change the name in the File Name box to indicate that this .XPT file is the format library, to prevent writing over an existing .XPT file.
  2. Click Save.
  3. You will immediately see a second Save As dialog box with the selection SAS Format Index Files (.SAS) in the Save as type drop-down box. You can use this file to assign the SAS format library to your dataset.

SAS Transport file Export .SAS Save As type

  1. Click Save.

A dialog box will tell you how many records were exported to the specified SAS transport file. If your data contains any variable names longer than 8 characters, you will receive an error (longer variable names must be exported to SAS XML format).

Tip: The transport or .XPT file contains each unique combination of Yes/No, Gender, Check Each, Pick One, Response Card Set, and Special Code Value Labels that were defined in the QDS Design Studio. The .XPT file can be viewed using the SAS System Viewer. The transport file is organized by streaming header records followed by data records. As such, the format library is a SAS transport data set. It must be converted to a SAS Format Catalog in SAS.

Convert SAS Transport File to SAS Format Catalog

To Load Data to the Format Library from the Transport File into SAS:

  1. Execute the .XPT formats file by double-clicking on the XPT file in Windows Explorer.
  2. SAS will start and read in the Format Library.
  3. Run the appropriate code to write out the data set to your SAS Library.

The following example code writes out formats from “Survey_f.XPT,” to a format library using the CNTLIN option in the SAS Format procedure:

/* Convert SAS Transport File to a SAS Format Catalog */

libname library 'c:\QDS\my data';

proc format library=library cntlin=Survey_f;

run;

If the name specified in the File Name box for the SAS format .XPT file is longer than 8 characters, the generated format dataset is truncated to 8 characters. For example, if the full SAS format .XPT filename was "Surveyformats.XPT," the truncated name should be referenced in the code: "cntlin=Surveyfo." In general, it is simpler to limit SAS dataset names to 8 characters or fewer.

Assign Formats to SAS Dataset

You can use the SAS format index file (*.SAS) generated by the Warehouse Manager to assign the formats to your SAS dataset. This syntax file contains the FORMAT statement for that format library (it is saved into the same location as the .XPT file).

Format names sometimes, but not always, correspond to the variable names (see QDS SAS Format Program Conventions). The example below assigns formats to a SAS dataset. Note that the appropriate library, data, and set statements need to be added to the SAS format index file (*.SAS) generated by the Warehouse Manager.

/* Write out formats to SAS dataset*/

libname library 'c:\QDS\my data';

data temp;

set library.Survey;

FORMAT

VISIT

VISIT.

GENDER

GENDER.

RACE

RACE.

JOB

FULLTIME

JOB.

EARLY

EXERC

DIET

AGREE.

FRUITA

FRUITB

FRUITC

FRUITD

FRUITE

FRUITF

FRUIT.

SERVING

SERVING.;

The following SAS error message(s) sometimes occur when running the PROC FORMAT statement:

  • ERROR: Format name ' ' is invalid. Observation ignored
  • ERROR: Format name '!!!!0000' is invalid. Observation ignored

They do not cause any problems with the resulting format library and can be disregarded.

Special Code Formatting

Special Codes defined in the Design Studio for Elements will have the following formats:

  • Don’t Know: "Don’t Know"
  • Refused: "Refused"
  • Not Applicable: "Not Applicable"
  • Skipped: No format applied. In cases in which both Not Applicable and Skipped apply and are assigned the same numeric code, the label "Not Applicable" is displayed.
  • Missing: No format applied.

If the SAS Save As Options are changed for Special Values Recodes to something other than "Special Codes" (default setting), these format labels do not apply.