BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gabyelle
Obsidian | Level 7

I am hoping someone might be able to shed some light on why options=fmtsearch(libref) does not work, but % include "filepath" does. I wonder what different syntax might be needed in SAS Studio in the the options statemement?

Below the code that does not work:

libname libref "/folders/myfolders/thefoldername";
options fmtsearch=(libref);
data mydata;
set thefoldername.mydata;
run;
proc sgplot data=mydata;
 title1 'Scatterplot of v1 vs v2';
 title2 'All Participants'; scatter x=v1 y=v2;
 xaxis values=(50 to 80 by 10);
 run; title;

the plot works fine, the correct number of observations are read in but the log show the formats are not loaded:

 

NOTE: Format YESNO was not found or could not be loaded.
NOTE: Format SES was not found or could not be loaded.
etc
 
As I mentioned earlier, using %include "filepath" works fine - formats are loaded.
 
I spent hours pouring over the boards and searching on the internet but to no avail. Could anyone help?
 
Thanks!
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Check the include files to see in which library the formats are created. Big chance that it is work, so your fmtsearch would be useless.

Keep in mind that including the .sas files executes the proc format and creates the formats on the spot, while fmtsearch only works for formats that have already been created with the format procedure.

View solution in original post

9 REPLIES 9
SASKiwi
PROC Star

I suspect there may be some misunderstanding here. %include is for including and running SAS code, which I'm guessing contains the code that creates the SAS formats.

 

For FMTSEARCH to work it needs to point to the SAS library where the SAS FORMAT catalog is created. By default, this will be the WORK library unless you specify otherwise. What you could try is this:

libname libref "/folders/myfolders/thefoldername";

proc format library = libref;
  * put your format code here;
run;
Reeza
Super User

You may want to explore using %include within your autoexec. Giventthat catalogs don't transfer systems, ie from Unix to Windows or 32bit to 64 bit is also an issue, it may be easier to stick with loading formats either as needed or at startup.

gabyelle
Obsidian | Level 7

Hello Reeza

 

Thanks for your reply - although I don't have the technical knowledge under my belt yet to understand what you mean with

 

"catalogs don't transfer systems"?

 

 

Kurt_Bremser
Super User

@gabyelle wrote:

Hello Reeza

 

Thanks for your reply - although I don't have the technical knowledge under my belt yet to understand what you mean with

 

"catalogs don't transfer systems"?

 

 


@Reeza means that SAS catalogs are version and operating system specific. A libref.formats catalog created with version X may not be usable with version Y. SAS programs, OTOH, can easily be used in different SAS versions and on different platforms.

proc format library=libref;
......
run;

options fmtsearch=(libref);

is totally portable, just the libname statement needs to be adapted.

Astounding
PROC Star

Just a possibility ...

 

When you don't specify the name of the catalog to look in to locate formats, it's assumed to be named formats.  So the catalog name that's being searched is libref.formats.  It's possible that the formats are actually saved under a different catalog name within that same libref.  You would have to specify the two-part name within the FMTSEARCH option, for example, libref.myformats or whatever the name actually is.

Kurt_Bremser
Super User

Check the include files to see in which library the formats are created. Big chance that it is work, so your fmtsearch would be useless.

Keep in mind that including the .sas files executes the proc format and creates the formats on the spot, while fmtsearch only works for formats that have already been created with the format procedure.

gabyelle
Obsidian | Level 7

Thanks very much Kurt - you have clarified a lot and I got to the bottom of it thanks to your hints - the formats weren't being loaded because the statement library=... after proc format was missing in the format file I had been given.

I also found out that there are two catalogs in SAS Studio - not just formats.sas7cat but also format.sas7cat - I can set the code to refer to either, by using library=libref.format or libref.formats - as long as I keep the reference consistent when I call the formats in the options fmtsearch=(libref.format(s)). 

As AmyP pointed out in another post on SAS catalogs, you can't actually see what is in the catalog directly (I tried the code snippets but cannot make much sense of the output as I can't open the individual catalogs).

 

As an aside, a difference I noticed when comparing logs produced after running %include and options fmtsearch=( ) is that the log doesn't confim the formats are loaded in the latter, but they appear to actually have loaded as the data displays the correct value labels.

 

I wonder why?

 

PS I also read your Maxims - very useful reading even for a beginner like me!

Kurt_Bremser
Super User

If SAS is given only a library name in fmtsearch, it will look for formats.sas7bcat in that library. But you can use any name for a formats catalog when you specify a two-level name (eg libref.format, note the missing "s") in fmtsearch.

 

The Maxims will be expanded in the future, so take a look every now and then. Suggestions are also welcome.

gabyelle
Obsidian | Level 7

OK - got it Kurt - thanks again!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 2568 views
  • 3 likes
  • 5 in conversation