okay I am pulling my hair out on this one.
I created some formats in the catalog as shown below, the feefmt and fee_format are my own, the rest are from the prep guide.
the code i used to create my own format is
proc format lib=formtlib; value feefmt 0-<100 = 'low' 100 - 500 = 'High'; run;
when I run the following code
proc print data=cert.admit;run; data admit_test; set cert.admit; format age agegroup. fee feefmt.; run; proc print data=admit_test;run;
the result I get is this
You can see that the format from the book is success but my own format failed, looking at the log I got
I don't understand my format failed, it was successfully loaded into the same directory as the prep guide formats, I don't see any wrong with my format, why did my format failed to load while prep guide worked fine?
Your formats in a custom format library stored in FORMTLIB cannot be used without the FMTSEARCH option being set properly.
options fmtsearch=(formtlib);
I deleted the entire catelog and retry again, now, nothing works, I mean it is right there in the when I check fmtlib
proc format lib=formtlib fmtlib; run;
you can see the three formats, but when I run
data work.carsurvey; set cert.cars; format Sex gender. Age agegroup. Color $col. Income Dollar8.; run; proc print data=work.carsurvey; run;
I get
log
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 70 71 data work.carsurvey; 72 set cert.cars; 73 format Sex gender. Age agegroup. Color $col. Income Dollar8.; _______ 484 NOTE 484-185: Format GENDER was not found or could not be loaded. 73 ! format Sex gender. Age agegroup. Color $col. Income Dollar8.; _________ 484 NOTE 484-185: Format AGEGROUP was not found or could not be loaded. 73 ! format Sex gender. Age agegroup. Color $col. Income Dollar8.; _____ 484 NOTE 484-185: Format $COL was not found or could not be loaded. 74 run; NOTE: There were 8 observations read from the data set CERT.CARS. NOTE: The data set WORK.CARSURVEY has 8 observations and 4 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds memory 953.90k OS Memory 29872.00k Timestamp 13/11/2022 03:50:54 AM Step Count 132 Switch Count 2 Page Faults 0 Page Reclaims 174 Page Swaps 0 Voluntary Context Switches 17 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 264 75 proc print data=work.carsurvey; 76 run; NOTE: There were 8 observations read from the data set WORK.CARSURVEY. NOTE: PROCEDURE PRINT used (Total process time): real time 0.02 seconds user cpu time 0.03 seconds system cpu time 0.00 seconds memory 2400.84k OS Memory 30380.00k Timestamp 13/11/2022 03:50:54 AM Step Count 133 Switch Count 0 Page Faults 0 Page Reclaims 297 Page Swaps 0 Voluntary Context Switches 0 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 8 77 78 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 89
Do I need to? The prep guide never said anything about FMTSEARCH option.
In fact it says SAS will search both work and permanent library anyway until the format is found.
Your formats in a custom format library stored in FORMTLIB cannot be used without the FMTSEARCH option being set properly.
options fmtsearch=(formtlib);
thanks, I spent 3 hours on this yesterday
@Nietzsche wrote:
Do I need to? The prep guide never said anything about FMTSEARCH option.
If the FMTSEARCH= system option was really not mentioned (I don't have the prep guide), I would rewrite that snippet of section 12.4 as follows:
Note that the special libref Library is also mentioned in the section "Permanently Storing Your Formats", of which you posted a screenshot in your other thread "few questions regarding to proc format", but it could easily be overlooked if that was the only occurrence.
IT WAS NOT MENTIONED AT ALL.
Ridiculous that the author would left this out!
here is the entire chapter 12 if you wish to search for that option.
If this training is produced by SAS , you should notify them of a major omission. If it is produced by some other author, you should notify the author.
I put all the errata I have found in this thread. SAS prep guides does not list the name of the author, so hopefully some SAS employee will refer to the SAS department that is responsible for the books to this thread and fix their errors and omissions in the next edition.
SAS will only search for formats that are in libraries that are in the fmtsearch path.
Since this is for a class, it is possible that the some of the setup code added the formtlib to the search path.
To check your fmtsearch setting, you can submit:
%put %sysfunc(getoption(fmtsearch)) ;
and look in the log. It will show the libraries that are in the search path, and the order in which they are searched.
Another thing to double-check is which directory the formtlib libref points to. To check that, you can submit:
%put %sysfunc(pathname(formtlib)) ;
and look in the log. From the instructions in the guide, they say it should point to C:\Users\studen1\formats\lib.
When you deleted the catalog (which was a good test to do), did you delete it from that directory or some other directory?
BTW, thanks for taking the time to submit a clear question, with code, annotated output, and logs! This sort of debugging is exactly the kind of thing that will make you pull out your hair, especially in the beginning.
Great explanation by Ron Cody in his book Getting-Started-SAS-Programming-Studio
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.