BookmarkSubscribeRSS Feed
anming
Pyrite | Level 9
libname myfmts "/folders/myfolders/formats";


will create a format library myfmts and format file will be saved as formats.sas7bdat in the formats folder. 

 

you can define a format name as $genderf in the format file

PROC FORMAT library=myfmts;
VALUE $genderf 'm'='Male' 'f'='Female';
run;

you can further write the second format names as group into the same format file.

PROC FORMAT library=myfmts;
VALUE asgroup 0-<60='F' 60-<70='D' 70-<80='C' 80-<90='B' 90-High='A'
Other='Missing';
run;

 the format file can be checked by 

proc format library=myfmts fmtlib;
run;

 

libname myfmts "/folders/myfolders/formats" ;
options fmtsearch=(myfmts work library);

proc print data = dataset1;
format gender $genderf. averagescore asgroup.;
run;

any misunderstanding?

 

2 REPLIES 2
SASKiwi
PROC Star

SAS formats are stored in SAS catalogs which have a file extension of sas7bcat.

 

If you want to call your SAS FORMATS catalog other than FORMATS then use LIBRARY = MyLib.MyFormats on your PROC FORMAT statement. 

ballardw
Super User

And if the name of the format catalog is other than Formats you need to reference it in the FMTSEARCH with libname.myfmts or what ever.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1096 views
  • 3 likes
  • 3 in conversation