1
votes

I have a macro in the precode of a SAS DI job, and inside there I have the following code:

%let mtransformid = %str(omsobj:TransformationStep\&TransformID);
%let rc = %sysfunc(metadata_getattr("&mtransformid","Name",transform_name));
%put &transform_name;

However, I keep getting the error message that the symbolic reference to &transform_name cannot be resolved on that last step. I've tried wrapping the call to metadata_getattr in a data step within the macro, but that didn't seem to help either:

%let mtransformid = %str(omsobj:TransformationStep\&TransformID);
data _null_;
    rc = metadata_getattr("&mtransformid","Name",trans_name);
    call symputx("transform_name",trans_name);
    %put &transform_name;
run;

The above %put statement results in the error message "Apparent symbolic reference TRANSFORM_NAME not resolved", unless I've "initialized" the macro variable earlier, in which case its previous value is output.

For reference, &TransformID is a macro variable that gets autogenerated by SAS DI for every transformation as it is run. Also, here are some relevant links that I've been trying to use to get ideas from:

Link 1

Link 2

Any help is greatly appreciated!

1
You're missing a ) on the second line - is that true in the actual code? - Joe
Also - if you've tried wrapping it in a data step, and want to go that route, include that code in the question if you want help with it, please! - Joe
Hey @Joe. Thanks for pointing out the missing bracket (no, this wasn't actual code, I did the silly thing of retyping instead of copy pasting). I will update with that fix as well as the code I used for the data step approach which did not work. - Rookatu
After the rc = ... do you try call symput like in link 1? If so, what happens? - Joe
Hi @Joe. Yes, I did try doing that and I got the message that the apparent symbolic reference was not resolved. I'll update the post with that info. - Rookatu

1 Answers

2
votes

It looks like you cannot use %sysfunc that way; the metadata_getattr function expects to return data to a data step variable.

As explained in this SAS Communities answer, you need to either use a data step or put your query into an FCMP function to use %sysfunc.