Hello,
I run into a problem when I reopened SAS. The format which can be loaded previously can not be loaded any more. I specify the libname for the formats and I can find and open them in SAS explorer. I used options fmtsearch= . However, when I try to set a dataset into another dataset, it always said "Format was not found or could not be loaded".
libname fmt 'C:\Users\hli\Desktop\work\project\HealthABC\Data\Formats';
libname PH 'C:\Users\hli\Desktop\work\project\HealthABC\Data\PH';
options fmtsearch=(fmt) ;
data ph;
set PH.ph;
keep HABCID HCFAID DOB RACE GENDER SITE VSTATUS DOD CV3DATE VITAL06M VITAL36M DTLASTCT LASTCTYP CV1AGE CV3AGE;
run;
ERROR: The format RACE was not found or could not be loaded.
ERROR: The format GENDER was not found or could not be loaded.
ERROR: The format SITE was not found or could not be loaded.
ERROR: The format STATUS was not found or could not be loaded.
ERROR: The format VTYPE was not found or could not be loaded.
...
Does anyone know the reason? Thank you.
You can also use the full name of the catalog in your FMTSEARCH option instead of just giving it a libref. If you only give it a one level name then it assumes you want the FORMAT catalog in that library.
ibname fmt 'C:\Users\hli\Desktop\work\project\HealthABC\Data\Formats';
libname PH 'C:\Users\hli\Desktop\work\project\HealthABC\Data\PH';
options fmtsearch=(fmt.formats64) ;
Check your folder C:\Users\hli\Desktop\work\project\HealthABC\Data\Formats for a file called formats.sas7bcat. If it doesn't exist then you will need to re-create your formats in that folder.
I do have all the formats on file...
Explain what you mean "that you have them on file."
When you compiled them did you assign your format library to them. e.g.,
libname art '/folders/myfolders'; libname fmt '/folders/myfolders/formats'; proc format library=fmt; value $sex 'M'='Male' 'F'='Female' ; value age 1-14=younger 15-20=young ; run; options fmtsearch=(fmt) ; data art.want; set sashelp.class; format age age.; format sex $sex.; run; data want; set art.want; run;
Art, CEO, AnalystFinder.com
I have a bunch of formats that are in .xpt format and I transfered them to SAS format. So I don't need to create any formats myself. However, somehow the formats cannot be loaded.
You have to convert them. An example can be found at: https://communities.sas.com/t5/Base-SAS-Programming/Convert-XPT-to-SAS-Datasets/td-p/97872
Art, CEO, AnalystFinder.com
I converted them. Right now, I have the SAS format in my specified folder. It actually worked after I transferred them, however, I closed the program. When I opened the program again, the format cannot be loaded any more.
Did you reassign the library and include it with the fmtserach option? If you always want those formats to be used you can include those assignments in your config file.
Art, CEO, AnalystFinder.com
@Heraaaa wrote:
I converted them. Right now, I have the SAS format in my specified folder. It actually worked after I transferred them, however, I closed the program. When I opened the program again, the format cannot be loaded any more.
Then there is something happening that removes the formats from the FMT library, or you are missing the necessary options fmtsearch= in your code.
Since I guess you use SAS with the Display Manager, you can use the SAS explorer to view the FORMATS catalog in the FMT library for its contents.
plaese post:
1) The code you used to convert the .xpt file into sas formats ?
Can it be that the formats were saved to work.formats catalog ?
2) Please run next code and check are those formats realy exist in TEST deataset:
libname fmt 'C:\Users\hli\Desktop\work\project\HealthABC\Data\Formats';
proc format lib=fmt cntlout=test; run;
Thank you all. I figured it out. In my format library, the formats are called formats64 (I named it when I imported them). After I changed the name to formats, the formats can be loaded.
You can also use the full name of the catalog in your FMTSEARCH option instead of just giving it a libref. If you only give it a one level name then it assumes you want the FORMAT catalog in that library.
ibname fmt 'C:\Users\hli\Desktop\work\project\HealthABC\Data\Formats';
libname PH 'C:\Users\hli\Desktop\work\project\HealthABC\Data\PH';
options fmtsearch=(fmt.formats64) ;
Thank you!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.