I would like to test if a format can be preloaded. Is there an easy way to test: "is a SAS format, calls a function, or contains a nested format in its definition."
520 proc summary data=sashelp.class completetypes; 521 class sex / preloadfmt; 522 format sex $upcase.; 523 output; 524 run; NOTE: Multiple concurrent threads will be used to summarize data. WARNING: The format for variable Sex cannot be preloaded. A finite set of formatted values cannot be produced from the format. The format is not recognized, is a SAS format, calls a function, or contains a nested format in its definition. Preload will have no effect. NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: The data set WORK.DATA1 has 3 observations and 3 variables.
Looks like perhaps having 'F' in HLO variable?
proc format cntlout=definition ;
value simple 1='One' 2='Two';
value compound 3='Three' other=[simple.] ;
value range 10-12='Pre-teen' 13-19='Teen' other='Other';
run;
proc print data=definition;
where fmtname in ('SIMPLE' 'COMPOUND' 'RANGE');
var fmtname type hlo start end label ;
run;
proc summary data=sashelp.class completetypes;
class age / preloadfmt;
format age simple. ;
output;
run;
proc summary data=sashelp.class completetypes;
class age / preloadfmt;
format age compound. ;
output;
run;
proc summary data=sashelp.class completetypes;
class age / preloadfmt;
format age range. ;
output;
run;
I would assume you could figure that out by looking the CNTLOUT dataset generated by PROC FORMAT for that format.
Did you try that?
Looks like perhaps having 'F' in HLO variable?
proc format cntlout=definition ;
value simple 1='One' 2='Two';
value compound 3='Three' other=[simple.] ;
value range 10-12='Pre-teen' 13-19='Teen' other='Other';
run;
proc print data=definition;
where fmtname in ('SIMPLE' 'COMPOUND' 'RANGE');
var fmtname type hlo start end label ;
run;
proc summary data=sashelp.class completetypes;
class age / preloadfmt;
format age simple. ;
output;
run;
proc summary data=sashelp.class completetypes;
class age / preloadfmt;
format age compound. ;
output;
run;
proc summary data=sashelp.class completetypes;
class age / preloadfmt;
format age range. ;
output;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.