BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sturg1dj
Fluorite | Level 6

Hello all!

I have run into an issue while trying to create a function that calls a macro.

%macro tester();

proc sql noprint;

select pay_for_perf_grp_name

into :name

from idisc.pay_for_perf_grp

where pay_for_perf_grp_id = &a;

quit;

/*data _null_;*/

/*set idisc.pay_for_perf_grp;*/

/*where pay_for_perf_grp_id = &a;*/

/*call symputx('name',pay_for_perf_grp_name);*/

/*run;*/

%mend;

PROC FCMP outlib=shared.funcs.test;

function tester(a) $;

     rc= run_macro('tester',a,name);

     IF rc = 0 then return(name);

     ELSE return('FAILED');

endsub;

run;

options cmplib=shared.funcs;

data test;

input pfp;

test = tester(pfp);

datalines;

1

146

147

30

;

run;


Result:

Capture.PNG

The idea is that there are ID's that are attached to names and I want the function to be able to call an oracle table and retrieve the names based on the functions.

I get no errors from running the code, but I get blanks as a result. If I change the function to pull the ID's instead and remove the $ then it does work (returns the ID's).


For the macro I tried using both the data step and PROC SQL and both came up with the same result. When I used a %put to see if it was working it showed that it was pulling the correct name. I have also changed the length of the return variable in the function statement and that does not work either.


Not sure what is going on.


Thanks!



EDIT:


The log indicates that when the variable is being pushed from the macro to the function it is being converted from a numeric to a character. However, I am wondering at what point did it ever become a numeric?


1 ACCEPTED SOLUTION

Accepted Solutions
sturg1dj
Fluorite | Level 6

The issue ended up being that I needed to have a length statement under the function.

View solution in original post

1 REPLY 1
sturg1dj
Fluorite | Level 6

The issue ended up being that I needed to have a length statement under the function.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2173 views
  • 0 likes
  • 1 in conversation