BookmarkSubscribeRSS Feed
0 Likes

Hi,

 

The data set is required to compile data set based hash functions in PROC FCMP. It is fine for run time compilations, but if you desire to store fcmp functions in a catalog and recompile them frequently creating actual data sets that feed into the functions/procedures is cumbersome. Furthermore, compiler does not really care about the metadata, but only if a dataset exists. The current workaround is to create dummy data sets for compilation. Needless to say not an optimal solution.

 

Thank you.

 

Current workaround:

%if %sysfunc(exist(&rules_ds.)) %then %let l_temp_var_rules_ds_created=0;
%else
	%do;
		/*		create dummy data set for compilation*/
		data &rules_ds.; run;
		/*		set a flag to wipe out the data set*/
		%let l_temp_var_rules_ds_created=1;
	%end;


proc fcmp outlib =&outlibname.;
function RULES_HASH_C (ruleid, rule_ref_name $ ) $
 	label="&rev. Retrieves all metadata for rule id.";
	 
	   length rule_name  rule_state rule_action $ 32 rule_label $ 256;

	   declare hash loansmeta_char (dataset:"&rules_ds.");
	   rc=loansmeta_char.definedata("rule_name","rule_state", "rule_action","rule_label");
	   rc=loansmeta_char.definekey("ruleid");
	   rc=loansmeta_char.definedone();
	   rc=loansmeta_char.find();


	   if STRIP(UPCASE(rule_ref_name))='RULE_NAME' then do; 
		   if rc eq 0 then return(LOWCASE(rule_name));else return('.N');
	   end;
	   else if STRIP(UPCASE(rule_ref_name))='RULE_STATE' then do; 
		   if rc eq 0 then return(rule_state);else return('.N');
	   end;
	   else if STRIP(UPCASE(rule_ref_name))='RULE_ACTION' then do; 
		   if rc eq 0 then return(rule_action);else return('.N');
	   end;
	    else if STRIP(UPCASE(rule_ref_name))='RULE_LABEL' then do; 
		   if rc eq 0 then return(rule_label);else return('.N');
	   end;
	   else return('**** rule ref name not defined ****');

	endsub;
quit;