DATA Step, Macro, Functions and more

Multiple format catalogues in one library

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

Multiple format catalogues in one library

[ Edited ]

I received data from a contractor recently that had format catalogues attached for each dataset. I've found that when there's more than one catalogue in a folder, SAS can't access either of them. Is there a particular reason for this, or is this a glitch? Also, is there a workaround for this, besides splitting each dataset into its own library and moving the associated catalogue with it?

 

Edit: Fixed the subject line. Not sure how I ended up with "PDF Multiple GMAPs into one Document"


Accepted Solutions
Solution
‎09-25-2015 01:40 PM
SAS Super FREQ
Posts: 708

Re: Multiple format catalogues in one library

Scify

 

The way you specified FMTSEARCH, SAS is looking for a catalog named TWOCATS.FORMATS. What is the name of the two catalogs?

 

Use TWOCATS.<catalogName> in FMTSEARCH for catalog names other than formats

 

Bruno

View solution in original post


All Replies
SAS Super FREQ
Posts: 708

Re: Multiple format catalogues in one library

Have you tried the FMTSEARCH System option?

 

Bruno

Contributor
Posts: 24

Re: Multiple format catalogues in one library

Posted in reply to Bruno_SAS

Yes. A rough of the code I have:

 

libname twocats "library-with-two-format-catalogues";

options fmtsearch=(main-library twocats);

proc freq data=twocats.stuff;
    table var1;
    format var1 var1.;
run;

 produces:

ERROR: The format var1 was not found or could not be loaded.

To avoid the obvious follow-up: I've double checked, and the format is in the catalogue. Other formats (in either catalogue) are also not found. 

Solution
‎09-25-2015 01:40 PM
SAS Super FREQ
Posts: 708

Re: Multiple format catalogues in one library

Scify

 

The way you specified FMTSEARCH, SAS is looking for a catalog named TWOCATS.FORMATS. What is the name of the two catalogs?

 

Use TWOCATS.<catalogName> in FMTSEARCH for catalog names other than formats

 

Bruno

Super User
Posts: 11,343

Re: Multiple format catalogues in one library

Your FMTSearch should look like:

 

options fmsearch=(twocats.catalog1 twocats.catalog2);

 

where catalog1 and catalog2 are replaced by the names of the actual catalogs in the library twocats.

 

I doubt that you have an actual library named main-library as well.

The FMTSEARCH doesn't seem to generate any errors with the syntax, just can't find format catalogs when attempting to use incorrect assignments.

 

You might want to use APPEND to add to your existing search path as well:

options append( fmtsearch (twocats.catalog1 twocats.catalog2));

So that any other libraries you have added to the search path are still valid.

Contributor
Posts: 24

Re: Multiple format catalogues in one library

The main-library bit was just pseudocode, because I ran into the problem of the fmtsearch option overwriting previous instances of itself.

 

I didn't know about the append option, though. Thanks. I've been having to remind my senior to include our primary format library whenever he runs the statement; it might be easier to just tell him to use append.

Super User
Posts: 11,343

Re: Multiple format catalogues in one library

Append is what I would recommend. Actually if you can get an autoexec file running at start up add the library assignments and the format search path there so they are always available.

 

Note that the FMTSEARCH is an in order left to right search assignment. If you have the same format in different libraries the one encounterd in the first library found will be used.

 

I maintain 7 permanent libraries and associated formats. I have many formats/ informats that start with the name of the library (or first few characters) so that they don't conflict.

 

I also routinely build custom formats for adhoc projects and store the formats with the data.

 

I would recommend using the option CNTLOUT on the proc format statement to create a dataset of the format descriptions as that can be useful in rebuilding the formats or providing a way to share them with someone else.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 420 views
  • 1 like
  • 3 in conversation