Converting SAS Formats from 32-Bit to 64-Bit

The SSCC has both 32-bit SAS and 64-bit SAS installed on Winstat. Our plan is to remove 32-bit SAS in 2013, ideally by the end of summer.

64-bit SAS has been the default on Winstat for some time, so if you haven't been making a special effort to use 32-bit SAS, you are already using 64-bit SAS. If you haven't run into any problems doing so, you can stop reading at this point. 64-bit SAS looks and acts just like 32-bit SAS, and programs you've written or data sets you've created using 32-bit SAS can be used in 64-bit SAS without any changes.

However, SAS catalog files containing formats that were created using 32-bit SAS cannot be read by 64-bit SAS. Unlike data files, catalog files are not portable across "platforms" and SAS considers 32-bit and 64-bit to be different platforms. If you've created customized formats using proc format and saved them as catalog files (see Storing SAS Formats for a discussion of how and why you might do so), you'll need to convert these formats to make them readable by 64-bit SAS.

Symptoms

Most likely, the problem will arise when you try to use a data set. The error message will be some variant on:

ERROR: File LIBRARY.FORMATS.CATALOG was created for a different operating system.
ERROR: Format FEM not found or couldn't be loaded for variable female.

In this case, the data set contained a variable female which was formatted using the custom format FEM. That format was saved in a catalog file (formats.sas7bcat) by 32-bit SAS. However, 64-bit SAS cannot read this catalog file. This prevents 64-bit SAS from reading the data set at all.

If you're opening a data set for viewing, all you'll see immediately is that it didn't work:

ERROR: Unable to open table

The error message about formats will be in the log.

You'll get a similar error message if you try to use 64-bit SAS to add formats to a 32-bit catalog file. It also doesn't work to have 64-bit SAS overwrite a 32-bit catalog file—note how the solutions below generally require that you delete or rename the 32-bit catalog file before creating a 64-bit version.

Solutions

There are several easy ways to fix this problem.

Solution 1: Remove the Format From the Variable

The very easiest is to simply not use the problem format. If you add the line:

format female;

to the data step or proc step you were trying to run, it will remove the FEM format from the female variable so there's no need to read the problem catalog file. However, if that format was actually useful you'll probably want to consider alternatives.

Solutution 2: Rerun proc format

If you still have the proc format code that created the catalog file in the first place, rerunning it using 64-bit SAS will create a catalog file that can be read by 64-bit SAS. Just be sure to delete or rename the 32-bit version first. This is the easiest solution that preserves the formats themselves.

Solution 3: Convert the Catalog to a Data Set and then Back to a Catalog

If you no longer have the proc format code, you can have 32-bit SAS convert the catalog file into a data set, then have 64-bit SAS convert the data set into a catalog file. This takes advantage of the fact that data sets, unlike catalogs, are portable between platforms.

First start 32-bit SAS and then run the following code:

libname mydir "catalog directory";
libname mylibrary (mydir);

proc format library=mylibrary cntlout=mydir.myformats;
run;

Replace catalog directory with the actual directory where the catalog is located (e.g. u:\) and myformats with the name of the catalog file (most likely formats). This program will create a data set called formats.sas7bdat in that directory, containing all the information about the formats in the catalog file.

Next delete or rename the existing catalog file, so that 64-bit SAS can create the new version.

Now start 64-bit SAS and run the following code:

libname mydir "catalog directory";
libname mylibrary (mydir);

proc format library=mylibrary cntlin=mydir.myformats;
run;

Again replace catalog directory with the directory where the data set is now located and the catalog file will be located, and myformats with the name of the catalog file to be created. This will read the data set and write the formats in a catalog file again.

Solution 4: proc cport / proc cimport

Use proc cport and proc cimport if you have lots of catalog files to convert and can put them in a single directory. They can also convert catalog files containing things other than formats (like saved graphics or macros). This process will also convert any data sets in that directory to the native 64-bit format, which allows 64-bit SAS to read them slightly faster.

The basic idea is similar to using 32-bit SAS to turn a catalog file into a data set which can be read by 64-bit SAS, but in this case you will create a single .cpt file containing all the catalogs and data sets in the directory, then let 64-bit SAS convert that .cpt file back into 64-bit versions of the original catalogs and data sets.

Begin by starting 32-bit SAS and running the following code:

libname project "catalog directory";
filename outfile "temp location/cport file.cpt";

proc cport library=project file=outfile;
run;

Replace catalog directory with the directory containing the catalog files. Replace temp location with a location where you can put the .cpt file (perhaps just u:\), and cport file with the name you want to give the .cpt file.

Close 32-bit SAS, rename the directory containing the catalog files so it can be recreated, start 64-bit SAS, and run the following code:

libname project "catalog directory";
filename outfile "temp location/cport file.cpt";

proc cimport library=project file=outfile;
run;

Again, replace catalog directory with the directory where the catalog files should go, replace temp location with a location where you put the .cpt file, and cport file with the name you gave it.

This will recreate the directory and all the files it contained.

No matter how you do the conversion, be sure to test your catalog files afterward and then delete the 32-bit versions if they are no longer needed.

Last Revised: 3/7/2013