Chapter 19. File Exchange Between MineSet and SAS

This chapter describes the support for file exchanges between MineSet and SAS.

Overview

Exchanging data sets between MineSet and SAS is done through two utilities: mineset2sas and sas2mineset. To convert a MineSet .schema and .data file pair into a SAS data set, use mineset2sas. To convert a SAS data set into MineSet .schema and .data files, use sas2mineset. Both mineset2sas and sas2mineset invoke the SAS executable; thus, SAS must be installed on the machine on which these conversion utilities are used.

Converting MineSet Data Files to SAS Data Sets

Use mineset2sas to convert MineSet data files into SAS data sets. The syntax for this is

mineset2sas <MineSet file> <SAS libref.datafile> [options]

Options are

  • -svsc to save the script sent to SAS. The script normally is deleted after use.

  • -names <namefile> to save trimmed column names in <namefile>. The script normally is deleted after use.

For example:

mineset2sas cars sasuser.cars -svsc -names cars.names

mineset2sas converts the MineSet .schema and .data files (in this case, cars.schema and cars.data) into a SAS data file. Currently, only string and numeric data types are supported. The MineSet .data file must be in ASCII format; binary format is not supported. To save MineSet data files in ASCII, deselect Use binary data files in Tool Manager Preferences.

SAS column names (or, in SAS terminology, variable names) can consist of only letters, and underscore characters. The first character in a column name cannot be a number. Furthermore, SAS column names can be up to eight characters long. Since any character string can be a legal MineSet column name, mineset2sas maps MineSet column names to legal SAS column names. The rules for this mapping are:

  • Any invalid character is replaced with an underscore.

  • If the first character is a digit, an underscore is prepended to the column name.

  • Column names are truncated to eight characters. If this truncation results in non-unique column names, the ends of the conflicting column names are replaced with sequential numbers, thus creating unique column names.

To preserve as much of the full column names as possible, mineset2sas also saves the first 40 characters of each column name as the column label.

The -names namefile Command Line Option

To get a listing of the column names before and after conversion into SAS format, specify the -names <namefile> command line option. When mineset2sas executes, it writes out a mapping of the column name changes to the specified file. For example:

  `date of birth`-> `date_of_`
  `92census`-> `_92censu`
  `# of days to end of quarter`-> `__of_da0`
  `# of days to end of year`-> `__of_da1`
  `# of davenports`-> `__of_da2`

The -svsc Option

The mineset2sas utility reads the schema for the specified data file, and writes a customized SAS script. SAS, which must be installed in /usr/sbin/sas, is invoked with this script to read and convert the data. The script sent to SAS is normally deleted after use. With the -svsc option, the script is saved as the file mineset2sas.sas. If there is an error in the script processing, the SAS error log is saved as mineset2sas.log.

Converting SAS Data Sets Into MineSet Data Files

Use sas2mineset to convert SAS data sets into MineSet data files. The syntax for this is

sas2mineset <SAS libref.datafile> <MineSet file> [options]

Options are

  • -nodata creates only a .schema file, no .data file.

  • -svsc saves the scripts sent to SAS.

  • -nolabel indicates that you do not want labels used for column names.

  • -names <namefile> restores long column names from <namefile>, created by mineset2sas.

For example,

sas2mineset sasuser.houses -svsc -names houses.names

The sas2mineset utility converts a SAS data file into MineSet .schema and .data files. Currently, this utility supports only string, numeric, and date data types.

The -nolabel Option

SAS only supports eight-character long column names, but allows optional 40 character labels for each column. MineSet sets no limit on the column name length, so, by default, sas2mineset uses the column labels to name the columns in the output file, if labels have been defined. To force sas2mineset to use the SAS column name for each column, even if a label is specified, add the -nolabel option to the command line.

The -names namefile Option

If a MineSet data file is converted into SAS with mineset2sas and then back to MineSet format with sas2mineset, a column name map file can be created to keep track of the original column names. To have sas2mineset use a name map file created by mineset2sas, add the -names <namefile> option to the command line, and specify the same map file as specified when the file was converted into SAS format with mineset2sas. This option is useful only for data files with column names longer than 40 characters, since mineset2sas saves up to 40 characters in the column label.

Note that the -name <namefile> option overrides the -nolabel option.

The -nodata Option

To create just a MineSet schema file without downloading the data from a SAS data file, add the -nodata option to the command line.

The -svsc Option

The sas2mineset utility writes two customized SAS scripts to retrieve the specified data file. The first script extracts column descriptions; the second extracts the data. The scripts are normally deleted after use. With the -svsc option, the scripts are saved as getschema.sas and getdata.sas, respectively. If there is an error in the script processing, the SAS error logs are saved as getschema.log and getdata.log, respectively.