Hello!
Currently there is no way to pass hash object(s) in/out of PROC FCMP functions.Specifically, when calling functions/procedures from within a data step. This ability would help tremendously with code simplification and modularization. Current, workarounds involve passing arrays back and forth or running hash within proc fcmp and passing out strings/arrays etc.
Thank you for consideration.
Something like this would be desired:
/*hash definition or population from ds*/
function MY_HASH1() hash;
length name1 name2 $ 32;
/* you can define structure/populate it manually or get it from ds*/
declare hash hashtopassout (dataset:"mylookup");
rc=hashtopassout.definedata("name1","name2");
rc=hashtopassout.definekey("id");
rc=hashtopassout.definedone();
return(hashtopassout);
endsub;
/*hash passing in out*/
/*this could also be call procedure*/
function PASS_HASH_INOUT(newid, newname $, hashobjectname hash) hash;
declare hash hashobjectname;
/* define data, key or iterator should be anchored to incoming hash object hashobjectname*/
/* i.e. adding/recplacing newid & newname*/
rc=hashobjectname.replace();
return(hashobjectname);
endsub;
/*use in data step*/
data dout; set somedata;
/* declare function from function hash*/
/*would allow modularization of all hash objects*/
declare hash hashobjectindataset(MY_HASH1());
declare hash hashobjectindataset2(MY_HASH1());
/* this could be also call procedure if this type of assignment would not work*/
hashobjectindataset2 = PASS_HASH_INOUT('23', 'sasideas', hashobjectindataset);
run;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.