I received a dataset and a format catalogue in SAS, and I am trying to get it to open, but somehow I am not correctly applying the format catalogue. Here is the code I've used. I have researched SAS sites and I thought I had the correct steps to call in the catalogue, but it's not working. I'm sure it's a basic error I'm making.
libname in 'U:/';
libname library 'U:/';
Options fmtsearch = (library.formats_raw);
data ae;
set in.ae;
format
aeactae $AEMGMT.
AEACTSM $ACTION.
AEDVIS $VISIT.
AEENDT DATE11.
AEINT $AEINT.
AEIRLOC $INJSITE.
AEIRMEAS $YESNO.
AEIRTERM $ISR.
AEIRVIS $VISIT.
AEIRYN $YESNO.
AEOUT $OUTCOME.
aerel $aerel.
AESER $YESNO.
AESTDT DATE11.
AEYN $YESNO.
EVTDT DATE11.
LASTUPD EURDFDT20.;
run;
For each variable, I get the following error in the log:
format
aeactae $AEMGMT.
--------
ERROR 48-59: The format $AEMGMT was not found or could not be loaded.
Edit: Given the new information the answer changes. I leave the rest in case it's useful.
You have a format dataset, not a format catalog. You need to run this:
to import the formats. This assumes it's created properly of course - it should have, at least,
fmtname,start,label, and probably some other variables also (type,hlo,endare common).This imports formats saved to a
SASdataset to the work environment. If you want to create a permanent catalog, you should specifylib=inor wherever you want them stored on theproc formatstatement.Old answer:
You're generally doing it right, though you're doing some things in ways you don't need to.
librarylibname should be avoided. It's something people use who don't know how to use formats properly, but it really is not a good idea, because it gets special preference in format searching in a way that can be problematic if you have more than one.LIBRARYandWORKare automatically in the fmtsearch list and are given first priority unless explicitly listed. But that doesn't actually help you when the format catalog is notformats.sas7bcatanyway.In your case you should just define it once (
in) and then do this:You put
workin there to make sure your format catalog gets priority over it.Then it should work, if you have a file
formats_raw.sas7bcatin that folder. If you don't, then you may have something else going on (you may have a file that's intended to be imported throughcntlinif it is a.sas7bdatfor example).This is a simple example of this working:
Change the
fmtsearchto(temp work)and you'll see it fail (sincetemp\formats.sas7bcatdoes not exist).