Summary

This article covers how to run the SAS decode file, locate library files, and format data to generate tables.

Table of Contents


After performing a SAS export with includeDecodeFile set to true, the exported files can be imported into SAS and used to generate tables. This decode file allows data values such as ’1′ and ’2′ in the forms to be replaced with display values such as ‘male’ and ‘female.’

Run the SAS Decode File

Before tables can be generated, the import SAS file must be opened and ran.

  1. In SAS select File > Open Program.


  2. Open the import.sas file.

Note: The name of the import file will depend on the name of the study. For example, a study called pmsDemo would have the SAS file name, importPmsDemo.sas.


After opening the file, the file’s contents will be displayed in the editor.

  1. At the top of the screen, click the ‘Submit’ button to run it.


  2. The Log will output the results of the run and report any errors.



Locate Library Files

Before formatting the data, it is recommended that you locate the library files as explained below. This will help assure that all tables and formatting data have been successfully created.

  1. In the Explorer Window, double-click the ‘Libraries’ icon to view the Active Libraries.


  2. Double-click the library name that pertains to the study.

Note: The library corresponds to the library name defined in the DA file.



The library should contain all of the form type files related to the study and a catalog folder containing all of the formatting data. Generally this catalog folder is called ‘Formats.’

  1. To view a table, double-click it in the Explorer window.
    The following example is of the Demographics table. Viewing these tables can help you to remember question type names and which columns need formatting.


  2. Right-click inside the Editor window to clear it before moving on.



Format the Data

  1. In the Editor, enter the following block of code. In this block of code, [library name] refers to the library name configured in the DA file. [name of catalog folder] refers to the formatting folder located inside the library folder.

options fmtsearch = 9[library name].[name of catalog folder]);


In the following example, the library is named ‘all’ and the catalog folder is named ‘formats.’

  1. At the top of the screen click the ‘Submit’ button to run the command.
    The Log will output the results of the run and report any errors.
  2. In the Editor, enter the following block of code to format the data. In this block, [form type] refers to the name of the form as it is displayed in the Library folder and [question type name] refers to a specific column name in the form.

proc print data = [library name].[form type]; format [question type name] [question type name]format.; run;


Example: To format the sex question in the Demographics table to display the display values ‘male’ and ‘female’ rather than the data values ’1′ and ’2,’ the following code could be used:

proc print data = all.Demog; format sex sexformat.; run;

 

Note: If the data type of the question is not a number, a ‘$’ must be included prior to the format name as shown in the following block of code. One instance where this could occur is when changing the nonnumerical data values ‘y’ and ‘n’ to the display values ‘yes’ and ‘no.’

 

format [question type name] $[question type name]format,;

 

  1. Click the ‘Submit’ button.

In the following example, the question types, sex and race, are formatted to display their string values rather than their numeric data values.


Need more help?

Please visit the Fountayn Contact Information page.