PROC FCMP: Returning Characters

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

PROC FCMP: Returning Characters

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?



Accepted Solutions
Solution
‎07-18-2014 08:41 AM
New Contributor
Posts: 4

Re: PROC FCMP: Returning Characters

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

View solution in original post


All Replies
Solution
‎07-18-2014 08:41 AM
New Contributor
Posts: 4

Re: PROC FCMP: Returning Characters

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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