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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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