DATA Step, Macro, Functions and more

How do I access SAS format libraries

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 139
Accepted Solution

How do I access SAS format libraries

Hello all;

 

So I am a little confused-  I had created some formats in such way: 

 

data F.locationxs          (keep =fmtname start label ); /*format for Hospital codes to hosp names*/
length LABEL $ 91 ;
fmtname='$STATIT';
set statitcodes;
LABEL=XXX_NAME;
START=facid;
OUTPUT F.locationxs;
proc format cntlin=F.locationxs;run;

 

And saved it a permanent library-

 

Now when I run-

Libname fmtlib "/apps/sas/datasets/data76/NCQOS/data/FORMATS";
OPTIONS FMTSEARCH=(fmtlib.FORMATS);

 

It is really weird as I can access the formats in one program but not in the other-

Any reason for this?

 

I am running this through SAS EG on a linux platform.

 

Thanks

 

Lawrence

 


formats.jpg

Accepted Solutions
Solution
‎03-17-2016 04:04 PM
Super Contributor
Posts: 441

Re: How do I access SAS format libraries

Hi Lawrence,

 

What FMTSEARCH actually does is point to a formats catalog that contains the formats you created. It sounds like you expect it to point to the dataset you created.

 

PROC FORMAT takes an input dataset through cntlin and creates what's called an entry (or entries) in a catalog. This catalog is called FORMATS by default and will be kept in a library, by default WORK. If the library is a permanent one you can point libname to it in a subsequent SAS session and have FMTSEARCH point to that catalog. Then your format will be available to that session and beyond.

 

Your code does not contain the option that directs PROC FORMAT to store the format in a catalog in a  permanent library. So what you should do is add LIBRARY=fmtlib to the PROC FORMAT statetement. That will create the expected catalog in the permanent library. In a new session your FMTSEARCH option would give the desired result. The cntlin dataset, once used by PROC FORMAT to create the catalog entry, can in fact be discarded (or kept for future reference). It can always be recreated with the inverse of CNTLIN, the CNTLOUT option.

 

If with this in mind, you read the SAS doc on the subject it should become crystal clear and you have gained yet another bit of the power to know.

 

Hope this helps,

- Jan.

View solution in original post


All Replies
Solution
‎03-17-2016 04:04 PM
Super Contributor
Posts: 441

Re: How do I access SAS format libraries

Hi Lawrence,

 

What FMTSEARCH actually does is point to a formats catalog that contains the formats you created. It sounds like you expect it to point to the dataset you created.

 

PROC FORMAT takes an input dataset through cntlin and creates what's called an entry (or entries) in a catalog. This catalog is called FORMATS by default and will be kept in a library, by default WORK. If the library is a permanent one you can point libname to it in a subsequent SAS session and have FMTSEARCH point to that catalog. Then your format will be available to that session and beyond.

 

Your code does not contain the option that directs PROC FORMAT to store the format in a catalog in a  permanent library. So what you should do is add LIBRARY=fmtlib to the PROC FORMAT statetement. That will create the expected catalog in the permanent library. In a new session your FMTSEARCH option would give the desired result. The cntlin dataset, once used by PROC FORMAT to create the catalog entry, can in fact be discarded (or kept for future reference). It can always be recreated with the inverse of CNTLIN, the CNTLOUT option.

 

If with this in mind, you read the SAS doc on the subject it should become crystal clear and you have gained yet another bit of the power to know.

 

Hope this helps,

- Jan.

☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 254 views
  • 0 likes
  • 2 in conversation