BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

@DRVAS wrote:

It really helps, but the problem arises already at the Oracle level, the database understands nothing but a comma separator. Therefore, I turned here for help

thanks for the advice


Personally I prefer to use space delimited list. Or if space is in the actual data then some other character, like | or ^ or ~.

Then if you need to convert them into commas to pass to something , usually SQL, that needs commas, you can always convert them in the macro.

%macro mymac(mylist);
%local mylistc;
%let mylistc=%sysfunc(translate(&mylist,%str(,),%str( )));
....
from connection to oracle 
( .... x in (&mylistc) ....);
...
%mend mymac;

%mymac(mylist=1 2 3 4 5);
unison
Lapis Lazuli | Level 10

Take a look at this approach.

 

%macro load_params(cell_package_sk=);

%put param passed in = &cell_package_sk.;

*removing parentheses..;
%let rm_parens = %sysfunc(compress(&cell_package_sk.,"()"));
%put string after removing parentheses = &rm_parens.;

*number of commas;
%let num_commas = %qsysfunc(countc(%superq(rm_parens),%str(,)));
%put number of commas (tokens = num_commas+1) = &num_commas.;

*loop over tokens;
%do i=1 %to &num_commas.+1;
	%let token = %qscan(%superq(rm_parens),&i.,%str(,));
	%put current token (&i.) = &token.;

	*----your code here---;
%end;
%mend;
%let input = (66387,66388);
%load_params(cell_package_sk=&input);

Realistically: If you're eventually parsing out the comma-delimited list and throwing that into your oracle statement, you shouldn't go through the trouble of using a comma-delimited list to begin with.

 

-unison

-unison
ballardw
Super User

Generate the code that makes this work without any macro variables or macro calls.

Once you have that working try the suggestions provided with your macro call.

Set OPTIONS MPRINT prior to running the macro.

Compare the results of the MPRINT output with the code that you wrote that worked.

DRVAS
Fluorite | Level 6

Good day.
Thank you all for your active help.
But the solution was unexpected.
Because When calling% Load_params, a delimited error occurred. Then we used the% NRBQUOTE function
Example:
% Load_Params (CELL_PACKAGE_SK =% NRBQUOTE (& CELL_PACKAGE_SK.));

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 18 replies
  • 28058 views
  • 9 likes
  • 7 in conversation