Skip to content

Instantly share code, notes, and snippets.

@statgeek
Created October 7, 2022 20:03
Show Gist options
  • Save statgeek/28a26ed1b1aef39f30b2fc9f9e494740 to your computer and use it in GitHub Desktop.
Save statgeek/28a26ed1b1aef39f30b2fc9f9e494740 to your computer and use it in GitHub Desktop.
Example of FMTSEARCH option usage in SAS
/*Author: F.Khurshed
Date: 2022-10-07*/
*create library to store format catalog;
libname demo '/home/fkhurshed/Demo1';
proc format;
value age_fmt
low - 12 = 'Child'
12-13 = 'Pre-Teen'
13-16 = 'Teen'
16-high = 'Young Adult';
run;
proc format lib=demo;
value age_fmt
low - 12 = '0 to 12 years old'
13-15 = '13 to 15 years old'
16-high = '16+ years old';
run;
title 'Default work library format';
proc print data=sashelp.class;
var age;
format age age_fmt.;
run;
title 'Using format from demo library';
*specify to use the format from the demo library first then check work;
options fmtsearch=(demo work);
proc print data=sashelp.class;
var age;
format age age_fmt.;
run;
title 'Using format from work library';
*specify to use the work library;
options fmtsearch = (work);
proc print data=sashelp.class;
var age;
format age age_fmt.;
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment