Only if they either sent you the code for creating the user-defined format or the SAS catalog containing it. You can use the SAS catalog to reverse engineer the code that created the format.
Just be clear that SAS datasets do not store SAS format definitions.
You can use PROC FORMAT to check if there are formats in a SAS catalog:
proc format library = MyLib.MyCatalog FMTLIB;
run;
Here is another example from the documentation.
If you think the library has formats (I'd bet against it if related to your previous question) you can use the following to have all formats outputed to a SAS data set with their defintions. If you're not familiar with CNTLIN/CNTLOUT data sets you may to read up on formats.
Change demo to the permanent library where the file is stored to check if the format exists.
proc format library=demo cntlout=check;
run;
@Ronein wrote:
Let's say that the guy who created the data set didn't sebd me the code of user defined format.
How can I check if the catalog containing it?
May you please show code for it?
*create a libname reference;
libname demo '/home/fkhurshed/Demo1';
*create a format in the library;
proc format library=demo;
value age_fmt
0 - 9 = 'Child'
10-12 = 'Pre-Teen'
13-19 = 'Teenager'
19-high = 'Adult';
run;
*Tell SAS to use this library for formats;
OPTIONS FMTSEARCH = ( demo );
*check that it works;
proc print data=sashelp.class;
format age age_fmt.;
run;
*output the format back to a dataset called check;
proc format library=demo cntlout=check;
run;
*print out format definition ;
proc print data=check;run;
To get a working version of a format, you need either
Without neither, you're hosed and have to resort to guessing.
The options are listed in order of being useful; code works everywhere, while catalogs and datasets may have issues with your platform.
Datasets live in files with SAS7BDAT extension. Formats live in catalogs. Catalogs live in files with SAS7BCAT extension. If they sent you a catalog file then you can check if the format is in that catalog by using PROC FORMAT.
Point a libref at the directory that contains the catalog. Then use the libref you created and the name of the catalog file with PROC FORMAT. So if the file is named 'mycat.sas7bcat' then the code might look like this.
libname mylib 'some directory';
proc format lib=mylib.mycat cntlout=formats;
run;
proc freq data=formats;
tables fmtname*fmttype / list;
run;
Note that catalogs are not readable across versions of SAS (or version of the operating system). So if they made the catalog in an earlier version of SAS or used a different operating system then you cannot read the file.
If you really want them to send you the definition they need to either use PROC CPORT to make a transportable version of the catalog. Or use the code above to make a dataset with the format definitions and send that dataset. Or just send the SAS statments to define the format(s).
This macro will export all the format definitions for a particular dataset, so long as they are contained in the FMTSEARCH path: https://core.sasjs.io/mp__getformats_8sas.html
Usage:
%mp_getformats(
lib=YOURLIB
,ds=YOURDATASET
,outsummary=work.summarytable
,outdetail=work.formatdetails
)
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.