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:
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.
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;
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.
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"?
@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.
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.
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.
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!
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.
OK - got it Kurt - thanks again!
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: