I have two different format catalogs which I need to use depending on how the client needs the output displayed.
%let fmt1=formats1 ;
%let fmt2=formats2 ;
libname fmts "\\path\formats" ;
options fmtsearch=(fmts.formats2 fmts.formats2 work library) ;
Each catalog has about 100 different formats, some of them the same and some different.
proc print data =mydata ; var var1-var3 ; run ;
So I want the data file to look into formats2 to apply the formats. Formats1 was created first and I have applied these formats to 'mydata' in a previous program. Now I want SAS to apply formats2 instead of formats1. I did what SAS said and put the order into the fmtsearch option, but I still get results showing the formats1 formats. What am I doing wrong? I'm running this in Batch.
Thanks!
Lorena
Your LIBNAME is invalid. Remove "="
libname fmts "\\path\formats" ;
ha was a typo... I have it written correctly in the program. Sorry!
This shouldn't happen, are you sure you don't have WORK or LIBRARY before user-defined catalog search libref and the format your searching exists.
The format search path creates an order of search for formats. If the requested format is not found in the first format catalog listen then it goes the next and so on until found (or not).
Your problem looks like the affective options statement is this one, not the one shows.
options fmtsearch=(fmts.formats1 fmts.formats2 work library) ;
I would verify that both of the catalogs exist at the time the code runs AND that the expected formats are in expected catalogs.
Right...it is very confusing because I feel like it should work too. The format I want is in formats2. In a previous program I had called formats1 and applied those formats. I have a question. Would it make more sense to use a datasets statement and remove all formats and then do the frmtsearch option? It makes no sense to me.
More information. I inherited a data file that had formats (formats1). How do I replace those formats with formats2? Maybe this is why it doesn't work, it keeps seeing the old formats from formats1?
Try adding this line of code immediately before the step where you get the misbehaving format usage:
Proc options option=fmtsearch;run;
That will write the actual in effect search path to the log.
Also you may want to run this code:
title "In FMTS.FORMATS1"; proc format library=FMTS.FORMATS1 fmtlib; ; run;TITLE; title "In FMTS.FORMATS2"; proc format library=FMTS.FORMATS2 fmtlib; ; run;TITLE;
to get human readable text of the contents to verify which catalog has which catalog has which formats and the assignments. Perhaps the issue is more subtle than the search order but that the format does not exist or is the wrong type in the Formats2 catalog.
More data will help us to understand what might be the problem. A small program that reproduces the problem would be even better.
What is the name of the variable that has a format attached to it? What format is attached to it? Does that format exist in only one of the format catalogs? Or both? Or neither? Are you sure that the format is the proper type for the variable that it is being used with?
Why do you need to keep both catalogs in the search path?
Are you redefining/changing your librefs? Are you sure that the LIBNAME statement ran without errors?
Someone showed me this undocumented function that a SAS based data explorer tool was using.
You might try adding this step after changing the FMTSEARCH path.
data _null_;
call fmtdel();
run;
Something is at play that you don't show.
Start with this working example, and slowly add your environment and data until you identify the breaking point.
options dlcreatedir;
libname T1 "%sysfunc(pathname(WORK))\T1" ;
libname T2 "%sysfunc(pathname(WORK))\T2" ;
proc format lib=T1; value $test 'A'='t1'; run;
proc format lib=T2; value $test 'A'='t2'; run;
options fmtsearch=(T1.FORMATS T2.FORMATS WORK);
data _null_; A='A'; put A= $test.; run;
options fmtsearch=(T2.FORMATS T1.FORMATS WORK);
data _null_; A='A'; put A= $test.; run;
A=t1 A=t2
options fmtsearch=(fmts) ;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.