Skip to Main Content

Copying and Combining SAS Format Libraries | SAS Code Fragments

How do you combine SAS format libraries? 

Say you have a format library in e:tempdata1 and a format library in
e:tempdata2 and you want to combine them.  Here is how you can do
this.  BEFORE YOU DO THIS, you should make a copy of the format library in
e:tempdata2 since it will be overwritten in this process.

libname first "etempdata1";
libname second "etempdata2";

proc catalog cat=first.FORMATS;
  copy out=second.FORMATS;
run;

What if the format library in e:tempdata1 was a version 6 format
library?  In that case, use the v6 engine like this.

libname first v6 "etempdata1";
libname second "etempdata2";

proc catalog cat=first.FORMATS;
  copy out=second.FORMATS;
run;

You can use this trick to copy a SAS version 6 format library
to a SAS version 8 format library, like below.  This copies e:tempdata1formats.sc2
to e:tempdata2formats.sas7bcat (a version 8 format library).

libname first v6 "e:tempdata1";
libname second v8 "e:tempdata2";

proc catalog cat=first.FORMATS;
  copy out=second.FORMATS;
run;

proc format library=second fmtlib;
run;